-
2. Re: MDB with Oracle and XA transactions: invalid transaction
frito Nov 22, 2002 3:48 AM (in response to frito)Hi Adrian,
thanks for your reply. I am glad someone cares for my problems :-)
But the link you gave me didn't really enlight me at all, even after reading it more than once. Perhaps it is too early in the morning ;-)
I think I just did everything mentioned in the forum thread you told me:
this is my ejb-jar.xml for the MDB receiving from QueueA and sending into QueueB:
[pre]<?xml version="1.0" encoding="UTF-8"?> <ejb-jar> <display-name>test/Test1</display-name> <enterprise-beans> <message-driven> <ejb-name>test/Test1</ejb-name> <ejb-class>gen.test.Test1MDB</ejb-class> <message-selector>filter = 'test/Test1'</message-selector> <transaction-type>Container</transaction-type> <resource-ref> <res-ref-name>managedQueueConnectionFactory</res-ref-name> <res-type>javax.jms.QueueConnectionFactory</res-type> <res-auth>Container</res-auth> </resource-ref> <resource-ref> <res-ref-name>managedQueueA</res-ref-name> <res-type>javax.jms.Queue</res-type> <res-auth>Container</res-auth> </resource-ref> <acknowledge-mode>Auto-acknowledge</acknowledge-mode> <message-driven-destination> <destination-type>javax.jms.Queue</destination-type> </message-driven-destination> </message-driven> </enterprise-beans> <assembly-descriptor> <security-role> <role-name>everyone</role-name> </security-role> <container-transaction> <method> <ejb-name>test/Test1</ejb-name> <method-name>onMessage</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar>
[/pre]
my jboss.xml:
[pre]<?xml version="1.0" encoding="UTF-8"?> <jboss> <resource-managers> <resource-manager> <res-name>managedQueueConnectionFactory</res-name> <res-jndi-name>java:JmsXA</res-jndi-name> </resource-manager> <resource-manager> <res-name>managedQueueA</res-name> <res-jndi-name>queue/QueueA</res-jndi-name> </resource-manager> <resource-manager> <res-name>managedQueueB</res-name> <res-jndi-name>queue/QueueB</res-jndi-name> </resource-manager> </resource-managers> <enterprise-beans> <message-driven> <ejb-name>test/Test1</ejb-name> <configuration-name>Test Message Driven Bean</configuration-name> <destination-jndi-name>queue/QueueA</destination-jndi-name> </message-driven> </enterprise-beans> </jboss>
[/pre]
The code in my MDB to get the Queue for sending:[pre] QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)jndiContext.lookup("java:comp/env/managedQueueConnectionFactory"); Queue queue = (Queue)jndiContext.lookup("java:comp/env/managedQueueB"); QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(); QueueSession queueSession = queueConnection.createQueueSession(true, 0); QueueSender queueSender = queueSession.createSender(queue); [/pre]
The code in my standalone client to get the Queues (sending in QueueA and receiving from QueueB:[pre] QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("XAConnectionFactory"); Queue sendQueue = (Queue) jndiContext.lookup("queue/QueueA"); Queue receiveQueue = (Queue) jndiContext.lookup("queue/QueueB"); QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(); QueueSession queueSession = queueConnection.createQueueSession(true, 0); QueueSender sender = queueSession.createSender(sendQueue); QueueReceiver receiver = queueSession.createReceiver(receiveQueue, messageSelector); [/pre]
Did I miss something?
Greetings again,
Frito -
3. Re: MDB with Oracle and XA transactions: invalid transaction
adrian.brock Nov 22, 2002 8:50 AM (in response to frito)Perhaps I didn't your question?
Can you explain where you get the error and give
a full stack trace and code snippet where the
error is thrown.
e.g. You are using transactional sessions,
where is the commit?
Regards,
Adrian -
4. Re: MDB with Oracle and XA transactions: invalid transaction
frito Nov 25, 2002 7:19 AM (in response to frito)Hello Adrian,
I found the problem while writing a minimal test client I wanted to attach my next posting:
I made a new instance of my QueueSession in ejbCreate(). Instead I should do this in onMessage(), since the transaction attribute "Required" is only set for the onMessage() method.
The EJB spec (15.4.9) sais, that ejbCreate() is called with an unspecified transaction context. Therefore I suppose it is not a bug when a resource (the QueueSession in my case) takes part at the transaction (the first one after newInstance()). Right? If not, I would report this as a bug.
Thank you once again a regards,
Frito