JMS

The JMS component is already included in the product. This page details how to connect to different JMS providers.

Library

Create a new library with the jar files of the JMS driver (see JMS provider documentation)

Connector

Create a JMS connector with the needed configuration.

TLS configuration

TLS connection should be configured on JMS server side and non encrypted communication should be forbidden. TLS configuration can be set through this JMS connector.

Route

Assuming the destination is a queue named test.

<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
    <route>
        <from uri="timer:foo?repeatCount=1"/>
        <setBody>
            <constant>TEST</constant>
        </setBody>
        <to uri="jms:queue:test?connectionFactory=ActiveMQ"/>
    </route>
</routes>

Transactional connector

In order to consume the messages inside a transaction, we need to setup your connectors with classes: 

  • Create a new JMS connector with the required configuration.
  • Create a new Other connector named transactionManager with the  org.springframework.jms.connection.JmsTransactionManager  class, with a reference to the previously created JMS connector
  • Create a new Other connector named transactionPolicy with the org.apache.camel.spring.spi.SpringTransactionPolicy class, with properties:
    • transactionManager : a reference to the previously created connector (transactionManager)
    • propagationBehaviorName : PROPAGATION_REQUIRED


And modify your route:

Routes definitions
<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
    <route>
        <from uri="jms:queue:QUEUE_NAME?transacted=true&amp;connectionFactory=connectionFactoryCache&amp;transactionManager=#transactionManager"/>
        <transacted ref="transactionPolicy"/>
        <to uri="log:QueueTransactionLog"/>
    </route>
</routes>

Related Links