(Sorry long one :( .. but pls have a look)
Applying your patch both test cases succeed for both tomee and bitronix/jvm
*BUT I am not convinced*.
The changes you suggested are:
*(1) In MyMessageReceiver.java*
session = conn.createSession(*false-->true*, Session.AUTO_ACKNOWLEDGE);
where the parameter is "boolean transacted".
This could make sense as the solution of the problem (even alone) BUT this
one alone is not enough to make tomee work and it seemed to be ignored
anyway in the Bitronix case, maybe overwritten by JTA.
*(2) In tomee.xml*
FROM:
<Resource id="MyAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig
ServerUrl tcp://fakehost:666
</Resource>
*
<Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
BrokerURL
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
</Resource>
<Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory"
class-name="org.apache.activemq.ActiveMQXAConnectionFactory">
BrokerURL
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
</Resource>
*
<Resource id="jms/MyOutgoingQueue"
class-name="org.apache.activemq.command.ActiveMQQueue">
PhysicalName MY_OUTGOING_QUEUE
</Resource>
<Resource id="jms/MyIncomingQueue"
class-name="org.apache.activemq.command.ActiveMQQueue">
PhysicalName MY_INCOMING_QUEUE
</Resource>
TO:
<Resource id="Default JMS Resource Adapter"
type="ActiveMQResourceAdapter">
BrokerXmlConfig =
ServerUrl =
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=0
</Resource>
*
<Resource id="jms/MyIncomingConnFactory"
type="javax.jms.ConnectionFactory" />
<Resource id="jms/MyOutgoingConnFactory"
type="javax.jms.ConnectionFactory" />
*
<Resource id="jms/MyOutgoingQueue" type="javax.jms.Queue">
PhysicalName = MY_OUTGOING_QUEUE
</Resource>
<Resource id="jms/MyIncomingQueue" type="javax.jms.Queue">
PhysicalName = MY_INCOMING_QUEUE
</Resource>
*In other words you give up using XA for active MQ BUT keep using XA for the
database :| .. and I don't get why*
In addition, when the "rollback" test case is run tomee logs this cryptic
exception:
------------------------------
11:00:22,944 INFO msgListenersTaskExecutor-1 com.test.MyMessageReceiver:50
- MESSAGE RECEIVED: Msg rollback Fri Nov 06 11:00:21 CET 2015 1446804021444
11:00:23,089 ERROR msgListenersTaskExecutor-1 com.test.MyMessageReceiver:59
- Rolling back the entire XA transaction (Message content includes the word
rollback)
r1:00:23,089 WARN msgListenersTaskExecutor-1 com.test.MyListener:936 -
Execution noofv J0M6S, m2e0s1s5a g1e1 :l0i0s:t2e3n eArM foarigl.eadp,a
cahned. gneor oEnrirmoor.Htarnadnlsearc thiaosn .bmeaenna gseert..T
:jnasvaac.tliaonngI.mRpuln teinmdeREexscoeuprtcieosn
.WRAoRlNlINedG b:a cEkr rboerc aeunsdei nogf aMsessoscaigaet icoonn tfeonrt
XiAnRcelsuoduersc et hoer gw.oarpda crhoel.ldbearcbky
r laite [email protected];M
etsrsaangsea(cMtyiMoens swaiglelR ercoelilv ebra.cjka.v aX:A6 8e)r
n ra tc oodreg:. s1p0r0i
Lofrrga.maepwaocrhke..jdmesr.blyi.sctleineenrt..Aabms.tXraaEcxtcMeepstsiaogne:L
iXsAt_eRnBeRrOCLoLnBtAaCiKn e:r .EdrorIonrv oekxeeLciusttiennge ra(
AXbAsRtersaocutrMcees.seangde(L)i,s tseenrevreCro nrteatiunrenre.dj
aXvAa_:R7B4R6O)L
r AaCtK .o
A .astp
roirngg.farpaamcehweo.rdke.rjbmys..clliisetnetn.enre.tA.bNsettrXaAcRteMseosusracgee.LtihsrtoewnXeArECxocnetpatiinoenr(.UinnkvnookwenL
iSsotuernceer)(
u sattr
aocrtgM.easpsaacgheeL.idsetrebnye.rcCloinetnati.nneert..jNaevtaX:A6R8e4s)o
. caet. eonrdg(.Usnpkrnionwgnf rSaomuerwcoer)k
a mast.
loirsgt.eanpearc.hAeb.sgterraocntiMmeos.stargaenLsiasctteinoenr.Cmoanntaagienre.rT.rdaonEsxaecctutieoLniIsmtpeln.eern(dARbesstoruarccteMse(sTsraagnesLaicsttieonneIrmCpoln.tjaaivnae:r5.8j3a)v
r 6a5t1 )o
c .aatp
aocrhge..sgperrionngifmroa.mterwaonrska.cjtmiso.nl.imsatneangeerr..ATbrsatnrsaaccttPioolnlIimnpglM.eesnsdaRgeesLoiusrtceense(rTCroanntsaaicnteiro.ndIomRpelc.ejiavveaA:n5d6E2x)e
o taet(
Aobrsgt.raapcatcPhoel.lgienrgoMneismsoa.gterLainsstaecnteiroCno.nmtaaniangeerr..jTarvaan:s3a1c5t)i
t Iamtp
lo.rrgo.lslpbraicnkg(fTrraamneswaocrtki.ojnmIsm.plli.sjtaevnae:r4.9A5b)s
: aactt
Poorlgl.ianpgaMcehses.aggeerLoinsitmeon.etrrCaonnstaacitnieorn..rmeacneaigveerA.nTdrEaxnescaucttei(oAnbMsatnraagcetrPIomlplli.nrgoMlelsbsaacgke(LTirsatnesnaecrtCioonntMaainnaegre.rjIamvpal:.2j3a3v)a
o 6a5t)
( ga.ts
porrign.gsfprraimnegwforrakm.ejwmosr.kl.itsrtaennsearc.tDieofna.ujlttaM.eJstsaaTgreaLnissatcetnieornCMoanntaagienre.rd$oARsoylnlcbMaecsks(aJgteaLTirsatnesnaecrtIinovnoMkaenra.gienrv.ojkaevLai:s1t0e4n8e)r
t eafta
uolrtgM.esspsraignegLfirsatmeenweorrCko.nttraainnsearc.tjiaovna.:s1u1p5p0o)r
. Aabts
torragc.tsPplraitnfgofrrmaTmreawnosrakc.tjimosn.Mlainsatgeenre.rp.rDoecfeasuslRtoMlelsbsaacgke(LAibsstternaecrtCPolnattafionremrT$rAasnysnaccMteisosnaMgaenLaigsetre.njearvIan:v8o5k3e)r
s uant(
Doerfga.uslptrMiensgsfargaemLeiwsotrekn.etrrCaonnstaacitnieorn..jsauvpap:o1r0t4.4A)b
t raatc
tjPalvaat.fuotrimlT.rcaonnscaucrtrieonntM.aTnhargeeard.PcooomlmEixte(cAubtsotrr.arcutnPWloartkfeorr(mTThrraenasdaPcotoiloEnxMeacnuatgoerr..jjaavvaa::1711435))
A aatt
ojragv.as.purtiinlg.fcroanmceuwrorrekn.tj.mTsh.rleiasdtPeonoelrE.xAebcsuttroarc$tWPoorlkleirn.grMuens(sTahgreeLaidsPtoeonleErxCeocnuttaoirn.ejra.vrae:c6e1i5v)e
n daEtx
ejcauvtae.(lAabnsgt.rTahcrtePaodl.lriunng(MTehsrseaagde.Ljiasvtae:n7e2r4C)o
tainer.java:247)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1150)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1044)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
*Caused by: org.apache.derby.client.am.SqlException: Error executing a
XAResource.end(), server returned XA_RBROLLBACK.
at
org.apache.derby.client.net.NetXAResource.xaRetValErrorAccumSQL(Unknown
Source)
... 14 more*
------------------------------
Which is a WARN and which could simply be the Derby XA driver informing you
that he was asked to rollback.
*But the same driver doesn't give any warning with the full XA Bitronix
solution* (which only gives the WARN about the onMessage having ended with
RuntimeException:
------------------------------
11:15:57,743 INFO msgListenersTaskExecutor-1 com.test.MyMessageReceiver:50
- MESSAGE RECEIVED: Msg rollback Fri Nov 06 11:15:57 CET 2015 1446804957489
11:15:57,778 ERROR msgListenersTaskExecutor-1 com.test.MyMessageReceiver:59
- Rolling back the entire XA transaction (Message content includes the word
rollback)
11:15:57,779 WARN msgListenersTaskExecutor-1 com.test.MyListener:936 -
Execution of JMS message listener failed, and no ErrorHandler has been set.
java.lang.RuntimeException: Rolled back because of Message content includes
the word rollback
at com.test.MyMessageReceiver.onMessage(MyMessageReceiver.java:68)
at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:746)
at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:684)
at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:651)
at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:315)
at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:233)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1150)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1044)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Running
------------------------------
So *what's the logical explanation behind this change?*
- tomee + activemq *XA* does not work in tomee (*but it does in bitronix*)
so we give up xa driver and are lucky anyway with non xa (??)
And then I am wondering: what about my initial scenario of having 2 ActiveMQ
systems one for incoming queue and one for outgoing, will non-XA work in
that case too? (And this is something I can test).
I also noticed that in the logs of tomee (with your patch) I keep having:
-----------------------------------
...
11:13:07,692 INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:13,710 WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:13,711 INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:19,723 WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:19,724 INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:25,738 WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:25,738 INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:31,748 WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:31,749 INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:37,766 WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:37,767 INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
11:13:43,780 WARN msgListenersTaskExecutor-1 com.test.MyListener:871 -
Setup of JMS message listener invoker failed for destination
'queue://MY_INCOMING_QUEUE' - trying to recover. Cause: Local JMS
transaction failed to commit; nested exception is javax.j
ms.IllegalStateException: Not a transacted session
11:13:43,780 INFO msgListenersTaskExecutor-1 com.test.MyListener:921 -
Successfully refreshed JMS Connection
...
-----------------------------------
What is your opinion about my comments and doubts?
--
View this message in context:
http://tomee-openejb.979440.n4.nabble.com/Tomee-MySql-ActiveMQ-XA-Distributed-Transactions-tp4676680p4676745.html
Sent from the TomEE Users mailing list archive at Nabble.com.