Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache Camel’s Multicast EIP sends one message to multiple configured endpoints. It runs the branches sequentially by default; add .parallelProcessing() to run them concurrently. Before the route continues, choose how branch replies are combined and how failures are handled.

Build a multicast route

Multicast is suited to fixed branches that each need to process the same message—for example, sending an order to inventory, pricing, and shipping checks. The following Java DSL illustrates the structure; it is not a tested, drop-in route. Check option availability and syntax against the Camel release used by your application.

from("direct:start")
    .multicast(new MyAggregationStrategy())
        .parallelProcessing()
        .to("direct:inventory")
        .to("direct:pricing")
        .to("direct:shipping")
    .end()
    .to("direct:afterMulticast");

The .end() closes the multicast block. The route’s next step, direct:afterMulticast, runs after branch processing completes, subject to any configured timeout. Apache Camel describes the pattern as routing the same message to multiple endpoints for different processing (Multicast EIP reference).

Choose sequential or parallel execution

Without parallel processing, Camel invokes branches in their declared order, one after another. Use .parallelProcessing() when branches can run independently and concurrent execution suits the workload. Parallel processing does not make the multicast fire-and-forget: normally, Camel waits for branch processing before proceeding beyond the block.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In parallel mode, the route may continue on a thread from the parallel processing pool. Add .synchronous() if downstream work must continue on the thread that entered the multicast. This controls continuation thread behavior; it does not make branches sequential. See the Camel 4.18.x Multicast reference for version-specific details.

Decide what happens to branch replies

Multicast produces one outgoing exchange after the branches, so decide what result that exchange should carry. If you do not provide an AggregationStrategy, Camel uses the last reply as the outgoing exchange. Provide a strategy when the route needs to combine branch results, or preserve input data while incorporating replies. Camel also documents a strategy method form that provides access to the original exchange.

Reply order matters to this decision. With streaming disabled, Camel processes replies in the order branches were declared. With .streaming() enabled, it processes replies as they arrive, which can be a different order. Keep declared order when a result’s position is meaningful; choose arrival order only when the strategy and downstream consumer can handle it.

Set the failure and timeout contract

By default, Camel continues through the remaining branches after a branch failure. That can be appropriate when partial results are useful, but the aggregation strategy and downstream route must account for missing or failed replies. Use .stopOnException() when a failure should stop further branch processing and propagate. Camel 4.18.x documents this to include exchange failures or faults and exceptions handled by an error handler. Test the interaction with your route’s error handling rather than assuming a partial result will be produced.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The timeout option sets a total time limit for parallel processing. When that limit is reached, Multicast breaks out and the route continues even if some replies have not completed. It is not a guarantee that all outstanding work has been cancelled: Camel 4.18.x notes that tasks difficult to shut down gracefully may continue running after timeout. Design branch operations and downstream handling for that possibility, and verify exact behavior in the documentation for your release.

Control branch preparation and unit of work

By default, each multicast exchange has its own unit of work. Set shareUnitOfWork only when branches are intended to share the parent unit of work and you understand the resulting error-handling semantics.

The onPrepare hook lets you prepare an exchange before it is sent to each branch. Camel identifies deep-cloning as one use case. Consider it when branch processors might mutate message content, but implement and verify the preparation behavior your application requires rather than assuming the hook deep-clones data automatically.

Choose the right related EIP

Pattern Use it when How it differs from Multicast
Multicast One message must go to a set of fixed route branches. Combines replies from that fan-out into one outgoing exchange.
Recipient List The recipients are supplied as a list at runtime. The destination set is dynamic rather than simply a set of fixed route branches.
Split One message contains parts that should be processed separately. It divides the input into parts instead of sending the same message to multiple destinations.
Aggregate Related incoming exchanges should be grouped by a correlation key and emitted as a completed group. It accumulates exchanges over time or by key; Multicast aggregates replies from one fan-out. See the Aggregate EIP reference.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep concurrency bounded and aggregation safe

A custom executorService configures the parallel-processing executor. Select capacity for your application’s workload and check pool behavior for the Camel runtime and release you deploy. Avoid treating concurrency as an automatic performance improvement: independent branches can run at once, but thread-pool capacity, endpoint behavior, and reply processing still shape the outcome.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

parallelAggregate is deprecated in the referenced documentation. It permits concurrent calls to the aggregation strategy only when that strategy is thread-safe; by default, strategy calls are serialized. Do not enable it as a routine performance switch. Consult the 4.18.x reference and the current Multicast reference for the release-specific option set.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.