0

How do I setup transaction in JMS route to rollback or not consume a message when an exception occurs. Below is my route. MQ is ActiveMQ.

from("jms:queue:myQueue")
        .routeId("myRoute")
        .doTry()
            .toF("reactive-streams:myStream")
        .doCatch(Exception.class)
            .process(exchange -> exchange.getFromEndpoint().stop())
        .end();`
Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
user3549576
  • 99
  • 1
  • 4
  • 17

1 Answers1

0

Simply adding transacted did the job! Also, had to enable connection pooling and camel-jms-starter (for default factories).

from("jms:queue:myQueue?transacted=true")
        .routeId("myRoute")
        .doTry()
            .toF("reactive-streams:myStream")
        .doCatch(Exception.class)
            .process(exchange -> exchange.getFromEndpoint().stop())
        .end();
user3549576
  • 99
  • 1
  • 4
  • 17