2
votes

According to Apache Camel documentation, "Camel supports the Guaranteed Delivery from the EIP patterns using among others the following components: ... JMS."

I'm trying to understand if this means I can use JMS in the middle of a multi-component route to "guarantee delivery."

For example, I have some routes that looks like this:

from("rest://post:someRestRoute")
    // blah blah
    .to("jms:queue:someQueue");

from("jms:queue:someQueue")
    // blah blah
    .to("spring-ws:someAddress")
    .to("someOtherRoute");

Does using JMS in the middle of a multi-component route have any benefits? Camel is writing to and reading from the queue, and the queue is running on the same computer and same JVM, so Camel is only guaranteeing delivery to itself, which seems redundant.

For example,

  1. A message is POSTed to someRestRoute.
  2. The message is queued and persisted on someQueue.
  3. The message is immediately dequeued.
  4. The message is sent to a webservice at someAddress.

As I understand it, as far as the JMS broker is concerned the message is "delivered" the moment it's successfully dequeued; it doesn't matter if spring-ws:someAddress throws an exception. I suppose this might be helpful if Camel crashed immediately after step 2, but I was hoping to guarantee delivery to someAddress.

Does using JMS in the middle of a multi-component route have any benefits? Can it be used to "guarantee delivery" to someAddress in the example?

1

1 Answers

2
votes

Only if your JMS queue is defined to persist messages. Then in case your route/application/server stopped before picking message, it will be in the queue until processed next time when route starts. If you do not need persistence then there is no reason to have JMS. Camel can be set to retry delivery to the endpoint in case of failure.

But, if you need persistence JMS is the best (if not only one) way to do it.