Re: Camel CDI with non JTA transaction manager?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Camel CDI with non JTA transaction manager?

Hi Gary,

Your understanding is correct. Transaction support in Camel CDI depends on JTA.

That being said, it is possible to use it in a Java SE environment by adding JTA API
and a transaction manager, as Narayana or Atomikos, in the classpath.

Then, you can produce Spring PlatformTransactionManager like:

PlatformTransactionManager createTransactionManager(TransactionManager transactionManager, UserTransaction userTransaction) {
    JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
    return jtaTransactionManager;

And the JMS component:

Component produceInputJmsComponent(@ConfigProperty(name = "jms.input.consumers") String inputQueueConcurrentConsumers) {
    CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(connectionFactory);
    return JmsComponent.jmsComponent(cachingConnectionFactory);


void disposeInputJmsComponent(@Disposes @Named("jms-input") Component component) {
    ((SingleConnectionFactory) component.getConfiguration().getConnectionFactory()).destroy();

So that, you can write in your Camel routes:


I’ve already seen it implemented successfully.


> On 18 Oct 2018, at 10:43, Gary Hodgson <[hidden email]> wrote:
> Hi,
> Is there a way to use JMSTransactionManager with cdi camel routes, i.e. not
> JTA? It seems from the documentation and from googling that only JTA is
> supported, and if this is the case then that entails camel-cdi is only
> usable in JavaEE environments (when transactions are to be used at least).
> We're using camel routes with CDI in a JavaSE environment but would like to
> utilise the Transactional Client EIP rather than relying on exception
> handlers.
> Any hints would be appreciated,
> Gary