jochenr commented on issue #2815:
URL: https://github.com/apache/camel-quarkus/issues/2815#issuecomment-1135519382

   Hi @gmagnotta,
   
   I tried your workaround
   
   `/**
    * Creates an instance of the Camel JmsComponent and configures it to 
support JMS transactions.
    *
    * idea from https://github.com/apache/camel-quarkus/issues/2815
    *
    */
   public class JmsComponentProducer {
   
       @Produces
       @Named("jmsxa")
       public JmsComponent createJmsComponent(@Named("xaConnectionFactory") 
ConnectionFactory connectionFactory, @Named("jtaTransactionManager") 
PlatformTransactionManager transactionManager) {
           JmsComponent jmsComponentTransacted = 
JmsComponent.jmsComponentTransacted(connectionFactory, transactionManager);
           jmsComponentTransacted.setIncludeSentJMSMessageID(true);
           jmsComponentTransacted.setUseMessageIDAsCorrelationID(true);
           jmsComponentTransacted.setTransacted(true);
                return jmsComponentTransacted;
       }
   
       // idea from
       // 
https://github.com/apache/camel-quarkus/blob/main/integration-tests/jta/src/main/java/org/apache/camel/quarkus/component/jta/it/XAConnectionFactoryConfiguration.java
   
       // This class should be remove if 
https://github.com/quarkusio/quarkus/issues/14871 resolved
       // And the ConnectionFactory could be integrated with TransactionManager
       @Produces
       @Named("xaConnectionFactory")
       public ConnectionFactory getXAConnectionFactory(TransactionManager tm, 
ArtemisRuntimeConfig config) {
           XAConnectionFactory cf = new ActiveMQXAConnectionFactory(config.url, 
config.username.orElse(null), config.password.orElse(null));
           return new ConnectionFactoryProxy(cf, new TransactionHelperImpl(tm));
   
       }
   
       @Produces
       @Named("jtaTransactionManager")
       PlatformTransactionManager createTransactionManager(UserTransaction 
userTransaction, TransactionManager transactionManager) {
           return new JtaTransactionManager(userTransaction, 
transactionManager);
       }
   
   }`
   
   It seems to work, if I only have one JMS endpoint in my route.
   If I have two endpoints like this:
   
   `
   from("direct:test")
        .transacted(TransactedDefinition.PROPAGATION_REQUIRED)
                .setBody(constant("Test JMS Message from Jochen"))
                
.to("jmsxa:queue:MyFirstQueue?exchangePattern=InOnly&jmsMessageType=Text")
                
.to("jmsxa:queue:MySecondQueue?exchangePattern=InOnly&jmsMessageType=Text")
   `
   
   
   I get this exception:
   2022-05-24 09:31:38,804 WARN  [com.arj.ats.jta] (executor-thread-0) 
ARJUNA016129: Could not end XA resource ClientSessionImpl 
[name=8c72c6ec-db33-11ec-83c8-0050b6fe9009, username=admin, closed=false, 
factory = 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl@1e72db50, 
metaData=()]@f5e1230: javax.transaction.xa.XAException
           at 
org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext.xaEnd(ActiveMQSessionContext.java:513)
   
   
   
   Have you tried your workaround with multiple jms endpoints?
   
   
   
   Does anyone know if there is a chance that 
[quarkus/issues/14871](https://github.com/quarkusio/quarkus/issues/14871) is 
solved soon?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to