Broadway Callbacks In Depth

Now that we have the tickets project set up, we are ready to start writing some code. Once a message comes from the message broker, we want to use it to create a ticket in the database for the customer and send a confirmation email to them.

To accomplish this, we are going to use the Broadway behaviour to configure and start the data-ingestion pipeline. There are four callbacks available for us to implement:

  • handle_message/3
  • prepare_messages/2
  • handle_failed/2
  • handle_batch/4

In this section, we’ll focus on the first three callbacks in the list. Don’t worry, we’re going to cover handle_batch/4 soon in Batching Messages.

First, create a new file bookings_pipeline.ex in the lib folder. Then define the module BookingsPipeline ...

Get Concurrent Data Processing in Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.