EIP Pattern in Apache Camel (Part – 2)

photo of a man programming
Reading Time: 3 minutes

This is Part 2 of an ongoing series of blogs explaining the EIP patterns (Enterprise Integration Patterns) in Apache camel. This blog is going to take you a step ahead and help you know more about the various EIP patterns such as WireTape, Multicast, and RecipientList EIP pattern

WireTap pattern

A wireTap pattern is used to filter messages based on content and read data from a message. WireTap allows routing the messages to a separate location while they are being routed to the ultimate destination. Additionally, WireTap is the fixed Recipient List with two output channels. It consumes messages off the input channel and publishes the unmodified messages to both output channels.  The WireTap uses a thread collection to process the tapped messages. All messages are sent as Event Messages and run in parallel with the original message. 

The wireTap sustains two different approaches to tapping an exchange:

  • copy of the original exchange.
  • new exchange instance to customize the tapped exchange.
1. Tap a copy of the original exchange

No filtering/modification is made in the original message




2. Tap and customize the original exchange:

Basically, they are following two approaches:

  • Processor approach
  • Expression approach

Processor approach: Using a processor gives you full power over how the exchange is populated as you can set properties, headers, and so on.


		.wireTap("direct:foo", new Processor() {

			public void new_process(Exchange ex) throws Exception {

				ex.getIn().setHeader("foo", "bar");




Expression approach: The expression approach can be used to modify the In message body.


                .wireTap("direct:foo", constant("Hello World"))



If you overuse wireTap to broadcast the output to multiple destinations. Subsequently, Multicasting or RecipientList is suitable for broadcasting.

Multicast pattern (Static RecipientList)

The multicast pattern sends the same message to a list of recipients. In addition, Regular or collection expressions define a recipient list. Below are the several ways of multicasting:

Multicasting Sequentially

To use multicasting, call multicast() in the Java DSL and then pass the destinations to the to() method. Below, we consume message from direct:start and it is multicast to three different destinations direct:x, direct:y, and direct:z.



                .to("direct:x", "direct:y", "direct:z");

or by multiple calls to to() methods in sequence.





Multicasting With Parallel Processing

A message is transmitted to multiple endpoints at the same time using parallel processing. 



                .to("direct:x", "direct:y", "direct:z");
Multicasting With Aggregation Strategy

An AggregationStrategy is for aggregating all the reply messages. 


                .multicast(new MyAggregationStrategy())

                .parallelProcessing().to("direct:x", "direct:y", "direct:z")



RecipientList (Dynamic RecipientList)

If you want to execute a task or set of tasks on a variable list of entities, the RecipientList pattern may be helpful. This pattern allows you to specify a list of recipients, and then run your workflow against all those entities in parallel. Further, To avoid sending confidential data to the wrong customer, one can use the recipient list pattern. Works with any type and amount of data. Basically, The recipients are specified in the message header and/or a property file (properties files) or as part of the body of the message.

Below, we consume messages from direct:start and it is multicast to three different destinations direct:a, direct:b, and direct:c.


                .multicast().to("direct:a", "direct:b", "direct:c");
Sending to multiple recipients in parallel
Stop continuing in case one recipient failed
Ignore invalid endpoints
Using custom AggregationStrategy
                        .aggregationStrategy(new UserDefinedAggStrategy())


In conclusion, you get an idea about the EIP pattern in Apache Camel. Stay tuned for the next part related to more EIP patterns such as Content-Based Routing, Aggregation, Splitter, Message filter 

Read Apache-Camel Manual for more knowledge.

Meanwhile, visit Knoldus Blogs to gain more information about different technologies.

Written by 

Kuldeep is a Software Consultant at Knoldus Software LLP. He has a sound knowledge of various programming languages like C, C++, Java, MySQL, and various frameworks like Apache Kafka and Spring/Springboot. He is passionate about daily and continuous improvement.