Static Batching

Learn about a batching technique called static batching.

Each message returned by the handle_message/3 callback must belong to a batcher. If one hasn’t been assigned, messages go to the :default batcher. This is the group we’ve already defined in start_link/1. Therefore, everything works, and we don’t need to do anything.

Static batching

Unlike :processors, the :batchers configuration supports multiple groups. This means we can have more than one batcher doing the work. We can use this to create batchers per event type. For example, we can have a :cinema batcher and a :musical batcher for cinema and musical bookings, while all other events go to the :default group. We call this static batching since batcher groups are hardcoded and are part of the pipeline configuration.

Add batchers

Let’s add some more batchers to our pipeline:

Get hands-on with 1200+ tech skills courses.