XA trasactions over a remote MQ queue Jboss 3.2.6
tnine Sep 13, 2006 12:15 PMI?m having some issue reading transitionally from a remote JBoss MQ Queue. I have configured the remote queue with the configuration defined here.
http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoIConfigureTheJMSResourceAdapterToUseARemoteConnectionFactory
With the exception of the following change in our ?ds.xml file
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=sun9.ata.com"> <attribute name="ProviderName">ATADevJMSProvider</attribute> <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute> <!-- The queue connection factory --> <attribute name="QueueFactoryRef">XAConnectionFactory</attribute> <!-- The topic factory --> <attribute name="TopicFactoryRef">XAConnectionFactory</attribute> <!-- Uncomment to use HAJNDI to access JMS --> <attribute name="Properties"> java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=jnp://sun9:7045 </attribute> </mbean>
We have the following code in our MDB
public void onMessage(Message message) { // MessageDrivenContext try { getDelegator().delegate(message); } catch (MessageDelegationException e) { LOGGER.fatal(e); // roll back the transaction if (!this.getMessageDrivenContext().getRollbackOnly()) { this.getMessageDrivenContext().setRollbackOnly(); } } }
And this ejb-jar.xml
<message-driven> <description> Bean to access messages from cats queues </description> <display-name>CATSMessageAccess</display-name> <ejb-name>ejb/CATSMessageAccess</ejb-name> <ejb-class> com.ata.utilities.mdd.MessageAccessBean </ejb-class> <transaction-type>Container</transaction-type> <acknowledge-mode>Auto-acknowledge</acknowledge-mode> <message-driven-destination> <destination-type>javax.jms.Queue</destination-type> </message-driven-destination> </message-driven>
If the POJO code fails by throwing an exception and the message tries to roll back the transaction, I get this exception and the message is removed from the queue on the remote server.
21:10:02,765 INFO [STDOUT] 21:10:02,765 INFO [SessionFactoryImpl] closing 21:10:02,765 ERROR [LogInterceptor] RuntimeException in method: public abstract void javax.jms.Messa geListener.onMessage(javax.jms.Message) java.lang.IllegalStateException: getRollbackOnly must only be called in the context of a transaction (EJB 2.0 - 15.5.1) at org.jboss.ejb.MessageDrivenEnterpriseContext$MessageDrivenContextImpl.getRollbackOnly(MessageDri venEnterpriseContext.java:192) at com.ata.utilities.mdd.MessageAccessBean.onMessage(MessageAccessBean.java:78) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:458 )
I thought I should be running in an XA container transaction, so when I roll back on my MDB, my local JDBC transactions do not commit (that works), and the read from the remote queue should roll back. Why am I not running in a transaction, and why does my remote queue lose the message? I?m assuming once I fix the local transaction problem, that the reading from the queue will succeed. Any help would be greatly apprecaited. I can't seem to find anything in the doc that would explain something I've missed. Reading from the queue works perfectly, it just doesn't happen in a transaction as expected.
Thanks,
Todd