What is the difference bewteen wiretap and multicast in Apache Camel

The wireTap component sends the message to just one route while the main flow continues.

The multicast router sends the message through multiple routes and waits for all of them to continue before the main flow can continue with the next message processor.

In the case of the old and deprecated multicast router, that happens synchronously, meaning that the main flow has to wait for the sum of all the routes execution times.

In 3.5 a new multicasting router called was introduced which does the same thing but in parallel, making the main flow only way for the slowest route.

Multicast : The Multicast EIP allows concurrency when sending a copy of the same message to multiple recipients.

WireTap: Wire Tap (from the EIP patterns) allows you to route messages to a separate location while they are being forwarded to the ultimate destination.

I don't think you can achieve concurrency by using wireTap to send a message in parallel to multiple recipients.

@Srikanth -

I don't think you can achieve concurrency by using wireTap

It is not quite correct. Concurrency will be there with WireTap as well as with Multicast with parallel processing.

It is main purpose of WireTap. As example for logging or auditing outside of main thread to do not slow main thread for non-functional operations.

Difference is:

  • WireTap is "one-way fork". Message goes to wire-tapped endpoint in different thread parallel to main and there is no way to get response back from it to main thread.

    Also it is possible to send to the wire-tapped endpoint other than main body, headers etc.

  • With Multicast it is possible to "split-then-aggregate" results in main thread after parallel or sequential processing.

    Also it is not limited how many endpoints will be multicasted, while WireTap can have only one endpoint to send to.