In my Camel Route I need to send message to a JMS when an Exception hits my onException
handlers. To speed up the main route, I try to send the messages asynchronously via a Wiretap
I try to use something like this:
onException().handled(true).logHandled(true)
.wiretap("seda:another_queue").end();
...
from("seda:another_queue?concurrentConsumers=5")
.to("jms:queue_for_my_exception_messages");
Is it necessary to use the Wiretap, or could I go with just the SEDA queues like this:
onException().handled(true).logHandled(true)
.to("seda:another_queue").end();
...
from("seda:another_queue?concurrentConsumers=5")
.to("jms:queue_for_my_exception_messages");
Wire Tap from the EIP patterns allows you to route messages to a separate location while they are being forwarded to the ultimate destination.
While the Direct and Direct-VM components take a synchronous approach to joining routes, SEDA does the opposite. It allows routes to be connected in an asynchronous way; that is, when a Camel route publishes a message to a seda: endpoint, the message is sent and control is returned immediately to the calling route.
SEDA is an architecture. The SEDA component in Camel uses in-memory queues in your process and are a separate component in order to distinguish them from the other queue component in Apache camel, namely the JMS component.
Contents. The Direct component provides direct, synchronous invocation of any consumers when a producer sends a message exchange. This endpoint can be used to connect existing routes in the same camel context. The SEDA component provides asynchronous invocation of any consumers when a producer sends a message exchange.
You do not need to use wiretap. Only seda-queues shall work.
Wiretap pattern should be used where you want to intercept messages between components for analysis or debugging purpose.
An important difference between Wiretap and SEDA is that when consuming from polling consumers (e.g. file or ftp) only wiretap is fire-and-forget.
When a thread consuming from a polling consumer reaches a .to(seda:xx)
it will hand off the exchange and continue the route as expected or consume new exchanges from the endpoint. The exchange delivered to the seda endpoint will be commited to the originating Consumer by the seda thread and not the original consumer thread. That means that if you for instance have delete=true
in your polling consumer endpoint definition, the file will not be deleted before the seda thread has finished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With