How to use the Camel PollingConsumer with JMS transactions?

Solution Verified - Updated -

Environment

  • Fuse Mediation Router 2.10 and below
  • Red Hat JBoss Fuse
    • 6.x

Issue

  • Camel's PollingConsumer can be used to explicitly consume messages from different endpoints including JMS.
  • Can I configure this consumer to work with JMS transactions or XA transactions?
  • Due to server timeout we are getting 500 Error and messages pulled from active mq are lost. In such cases we want to rollback the transaction and put them back into queue. Is this possible ?

Resolution

Camel's PollingConsumer is not meant to be used with JMS or XA transactions. Using that utility class you don't really have access to the underlying JMS session nor to the transaction manager, so it is not possible to use it with either local JMS transaction or XA transactions.
Transaction support in Camel is really provided on the route level (e.g. using the Camel jms component).

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments