AFAIK the transaction manager jndi name is not standard (user transaction one is) and current one is not zven the "common" one which is in comp/ for webapps so IMHO:
- camel-cdi must not have any ee feature (deployment should theorically fail if validated since injection must not work in standalone) - either jta integration should use user transaction or make tx mgr name/static method configurable as in https://github.com/apache/openjpa/blob/08bb3a5a0e7573622aa6dc25763cb6513095093b/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AutomaticManagedRuntime.java#L55 Le mer. 2 sept. 2020 à 08:33, Zheng Feng <zf...@redhat.com> a écrit : > FYI, I just raised https://github.com/apache/camel/pull/4151 to backport > the fix of CAMEL-14918 to 3.4.x. Also I test the "transacted=true" which > the sjms consumer that the message will be sent to the DLQ after the error > handler is exhausted. Is this what you expected ? > > On Wed, Sep 2, 2020 at 2:09 PM Zheng Feng <zf...@redhat.com> wrote: > > > Yeah, TomEE could provide the "java:/TransactionManager" since it is a > > J2EE container. I wonder if you use the "transacted=true" option on the > > sjms consumer which will rollback the transaction if the router is > failed. > > > > > > On Tue, Sep 1, 2020 at 4:35 AM Shultz, Dmitry <dmitry_shu...@kaltire.com > > > > wrote: > > > >> Thanks for the reply Zheng. > >> > >> I'm running very similar code in the TomEE and It doesn't fail on NPE. > >> See similar behaviour though: > >> > >> [Thread-0 (ActiveMQ-client] WARN o.a.c.jta.TransactionErrorHandler - > >> Transaction rollback (0x30730302) redelivered(false) for (MessageId: > >> ID:9fd77209-ebc6-11ea-955a-1ee7171b8787 on ExchangeId: > >> ID-Kal030841-1598904862181-0-2) caught: test > >> > >> And after process restart the message is gone. > >> > >> I can confirm that when I use infinite re-delivery (the error handler > >> never exhausted) the message stays in the durable topic as forever even > >> after restart. So, I'm not sure if my expectation are correct i.e. does > it > >> supposed to stay in the topic after error handler redeliveries are > >> exhausted? > >> > >> Cheers, > >> Dmitry > >> > >> > >> -----Original Message----- > >> From: Zheng Feng [mailto:zf...@redhat.com] > >> Sent: Sunday, August 30, 2020 8:58 AM > >> To: users@camel.apache.org > >> Subject: Re: CDI + SJMS + transacted > >> > >> Hi Dmitry, > >> > >> It seems that SJMS [1] currently only supports the use of internal JMS > >> Transactions. There is no support for the Camel Transaction Processor or > >> the Java Transaction API (JTA). Also if you want to use the JTA > transaction > >> provided by the camel-cdi, the TransactionManager should be available > via > >> JNDI "java:/TransactionManager". Then you are running the camel in the > >> standalone environment, and the transaction manager should be provided > by > >> the third party implementation, such as Narayana ( you can find the jta > >> standalone example here [2]). The NPE I think should be fixed by > >> CAMEL-14918 [3], and I will try to backport it to the 3.4.x > >> > >> Regards, > >> Zheng Feng > >> > >> [1] > >> > https://urldefense.com/v3/__https://camel.apache.org/components/latest/sjms-component.html__;!!LdWlNaMnLCM!OJ-X6YfRy0exjKJ8PNWy-d5aHbD6mgnBfTRZXXKak6kEojLVTmcKwcF4puKY9P1BTwqO$ > >> [2] > >> > https://urldefense.com/v3/__https://github.com/jbosstm/quickstart/tree/master/jta-1_2-standalone__;!!LdWlNaMnLCM!OJ-X6YfRy0exjKJ8PNWy-d5aHbD6mgnBfTRZXXKak6kEojLVTmcKwcF4puKY9Py3UShj$ > >> [3] > >> > >> > https://urldefense.com/v3/__https://github.com/apache/camel/commit/4421b2bba294dd8828621684c7670f78d811ecd8*diff-773b20d331dac13fb17acfa0f58ac01f__;Iw!!LdWlNaMnLCM!OJ-X6YfRy0exjKJ8PNWy-d5aHbD6mgnBfTRZXXKak6kEojLVTmcKwcF4puKY9F_CLTBw$ > >> > >> On Sat, Aug 29, 2020 at 5:50 AM Shultz, Dmitry < > dmitry_shu...@kaltire.com > >> > > >> wrote: > >> > >> > Hi All, > >> > > >> > I'm probably doing something wrong/stupid, but I can't get the sjms > >> > (recent Camel, but same true for 2.25.2) to leave failed messages in > >> > the JMS topic (AMQ Artemis) after exception. > >> > This is what logged: > >> > > >> > [ctiveMQ-client-global-threads)] TransactionErrorHandler WARN > >> > Transaction rollback (0x5cd1283) redelivered(false) for (MessageId: > >> > ID:bbaa590d-e975-11ea-9ad0-6c4b902fc0e1 on ExchangeId: > >> > ID-Kal030841-1598650245838-0-1) caught: null > >> > [ctiveMQ-client-global-threads)] TransactionErrorHandler WARN > >> > Transaction rollback (0x5cd1283) redelivered(false) for (MessageId: > >> > ID:bbaa590d-e975-11ea-9ad0-6c4b902fc0e1 on ExchangeId: > >> > ID-Kal030841-1598650245838-0-1) caught: null > >> > [ctiveMQ-client-global-threads)] TransactionErrorHandler WARN > >> > Transaction rollback (0x5cd1283) redelivered(false) for (MessageId: > >> > ID:bbaa590d-e975-11ea-9ad0-6c4b902fc0e1 on ExchangeId: > >> > ID-Kal030841-1598650245838-0-1) caught: null > >> > [ctiveMQ-client-global-threads)] TransactionErrorHandler ERROR > >> > Failed delivery for (MessageId: > >> > ID:bbaa590d-e975-11ea-9ad0-6c4b902fc0e1 on > >> > ExchangeId: ID-Kal030841-1598650245838-0-1). Exhausted after delivery > >> > attempt: 3 caught: java.lang.NullPointerException > >> > > >> > Message History (complete message history is disabled) > >> > > >> > > >> > --------------------------------------------------------------------------------------------------------------------------------------- > >> > RouteId ProcessorId Processor > >> > Elapsed (ms) > >> > [route1 ] [route1 ] > >> > [from[sjms://topic:topic:test?durableSubscriptionId=dmitr] [ > 1999] > >> > ... > >> > [route1 ] [transacted1 ] [transacted > >> > ] [ 0] > >> > > >> > Stacktrace > >> > > >> > ---------------------------------------------------------------------- > >> > ----------------------------------------------------------------- > >> > > >> > java.lang.NullPointerException: null > >> > at > >> > org.apache.camel.cdi.transaction.TransactionalJtaTransactionPolicy.has > >> > ActiveTransaction(TransactionalJtaTransactionPolicy.java:105) > >> > ~[camel-cdi-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.cdi.transaction.RequiredJtaTransactionPolicy.run(Requ > >> > iredJtaTransactionPolicy.java:26) > >> > ~[camel-cdi-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.jta.TransactionErrorHandler.doInTransactionTemplate(T > >> > ransactionErrorHandler.java:193) > >> > ~[camel-jta-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.jta.TransactionErrorHandler.processInTransaction(Tran > >> > sactionErrorHandler.java:144) > >> > ~[camel-jta-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.jta.TransactionErrorHandler.process(TransactionErrorH > >> > andler.java:108) > >> > ~[camel-jta-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.jta.TransactionErrorHandler.process(TransactionErrorH > >> > andler.java:117) > >> > ~[camel-jta-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$Redeliv > >> > eryTask.redeliver(RedeliveryErrorHandler.java:766) > >> > ~[camel-base-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(D > >> > efaultReactiveExecutor.java:148) > >> > ~[camel-base-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(Defa > >> > ultReactiveExecutor.java:60) > >> > ~[camel-base-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.processor.Pipeline.process(Pipeline.java:147) > >> > ~[camel-base-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.processor.CamelInternalProcessor.process(CamelInterna > >> > lProcessor.java:286) > >> > ~[camel-base-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process > >> > (DefaultAsyncProcessorAwaitManager.java:83) > >> > ~[camel-base-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.support.AsyncProcessorSupport.process(AsyncProcessorS > >> > upport.java:40) > >> > ~[camel-support-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.component.sjms.consumer.InOnlyMessageHandler.handleMe > >> > ssage(InOnlyMessageHandler.java:52) > >> > ~[camel-sjms-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.camel.component.sjms.consumer.AbstractMessageHandler.onMess > >> > age(AbstractMessageHandler.java:81) > >> > ~[camel-sjms-3.4.3.jar:3.4.3] > >> > at > >> > org.apache.activemq.artemis.jms.client.JMSMessageListenerWrapper.onMes > >> > sage(JMSMessageListenerWrapper.java:110) > >> > ~[artemis-jms-client-2.14.0.jar:2.14.0] > >> > at > >> > org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.callOn > >> > Message(ClientConsumerImpl.java:1030) > >> > ~[artemis-core-client-2.14.0.jar:2.14.0] > >> > > >> > So, it looks like rollback is kicked off, but when I restart the > >> > process message is gone from the JMS topic. > >> > > >> > Sample reproducer (generated using > >> > -DarchetypeArtifactId=camel-archetype-cdi as described here > >> > > https://urldefense.com/v3/__https://camel.apache.org/components/latest > >> > /others/cdi.html__;!!LdWlNaMnLCM!OJ-X6YfRy0exjKJ8PNWy-d5aHbD6mgnBfTRZX > >> > XKak6kEojLVTmcKwcF4puKY9NnrgwcA$ ) is here > >> > > https://urldefense.com/v3/__https://github.com/zeppelinux/CamelCDISjms > >> > Test__;!!LdWlNaMnLCM!OJ-X6YfRy0exjKJ8PNWy-d5aHbD6mgnBfTRZXXKak6kEojLVT > >> > mcKwcF4puKY9HBU5Opk$ > >> > Please have a look. > >> > > >> > Cheers, > >> > Dmitry > >> > > >> > > >