Hi Antonin,
Thanks for the response. I'll revisit my previous attempts at integrating
standalone JTA - I believe I got a working example going, but had to put it
on hold during the testing. If I get a sufficiently good example going
then I'll post a link here in case it's useful for others.
Cheers,
Gary
From: Antonin Stefanutti <>
To: "***@camel.apache.org" <***@camel.apache.org>
Cc:
Bcc:
Date: Thu, 18 Oct 2018 09:45:42 +0000
Subject: 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:
@Produces
@Singleton
@Named("jtaTransactionManager")
PlatformTransactionManager createTransactionManager(TransactionManager
transactionManager, UserTransaction userTransaction) {
JtaTransactionManager jtaTransactionManager = new
JtaTransactionManager();
jtaTransactionManager.setUserTransaction(userTransaction);
jtaTransactionManager.setTransactionManager(transactionManager);
jtaTransactionManager.afterPropertiesSet();
return jtaTransactionManager;
}
And the JMS component:
@Produces
@Named("jms-input")
@ApplicationScoped
Component produceInputJmsComponent(@ConfigProperty(name =
"jms.input.consumers") String inputQueueConcurrentConsumers) {
CachingConnectionFactory cachingConnectionFactory = new
CachingConnectionFactory(connectionFactory);
cachingConnectionFactory.setSessionCacheSize(Integer.parseInt(consumers));
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:
from("jms-input:queue:{{jms.input.destination}}?transacted=true&concurrentConsumers={{jms.input.consumers}}&transactionManager=#jtaTransactionManager&cacheLevelName={{jms.input.consumers.cacheLevel}}")
Iâve already seen it implemented successfully.
Antonin
Post by Gary HodgsonHi,
Is there a way to use JMSTransactionManager with cdi camel routes, i.e.
not
Post by Gary HodgsonJTA? 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
Post by Gary Hodgsonutilise the Transactional Client EIP rather than relying on exception
handlers.
Any hints would be appreciated,
Gary