Author |
Message
|
meetgaurav |
Posted: Mon Sep 08, 2008 11:03 pm Post subject: WebSphere MQ JMS AND XA TRANSACTIONS |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
[b]The Using Java manual has 2 distinct sections. One is "Programming with WebSphere MQ base Java", the other is "Programming with WebSphere MQ JMS". [/b]
I Used MQ JMS and finished the process and now my MDB is listening to the QUEUE. Now we have a plan to implement XA transactions. The Methods BackOUt and Commit will available in MQQueueManager which is in MQ base Java.
Any One please assist Me. Is there any way to implement XA transactions in MQ JMS
Cheers,
Gaurav |
|
Back to top |
|
 |
meetgaurav |
Posted: Tue Sep 09, 2008 2:45 am Post subject: How to Use commit and backout in WebSphere MQ JMS Interface |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
My MDB is litening to the MQ Queue which is in UNIX machine. As soon as my MDB picks a message from the Queue it gets deleted. In case of any exception am just rollback the context and this works fine for Me.
MessageDrivenContext context;
context.setRollbackOnly();
In case of system failure or the system crashes I cant rollback my message which is in MQ queue.
AM Using
----------
Websphere MQ
OC4J Server
Can anyone please assist Me,
Thanks
Gaurav |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 09, 2008 7:09 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The transactionality is handled at the session level. As you have already noticed this is passed in the MDB Context. The transactionality is set on the MDB deployment descriptor. If the system crashes you have a transaction in flight. I would hope that Oracle App Server (OC4J) like WAS is able to pick up transactions in flight and try a recovery on them while coming back up.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
meetgaurav |
Posted: Tue Sep 09, 2008 9:44 pm Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
Hi FJB_SAPER
I will agree that the context rollback is working in case of any exceptions (Any exceptions in bussiness logic or the Reply Queue is not ready). But in case of system failure or the server crashes I was unable to get that message.
XA transactions Will help for me. If so How ?? Any sample codes are there?? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 10, 2008 2:34 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You mean to say that your DB action taken upon onMessage() is done through an entity EJB that does not have requires transaction on the deployment descriptor????  _________________ MQ & Broker admin |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 10, 2008 2:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You know you could also use Oracle's MQ/AQ messaging gateway and have your application only use Oracle native JMS provider (AQ)  _________________ MQ & Broker admin |
|
Back to top |
|
 |
meetgaurav |
Posted: Wed Sep 10, 2008 4:03 am Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
HI FJB_SAPER
I think Still U R not clear with my problem.
* WEBSPEHRE MQ
* OC4J where the MDB is deployed
Actually My MDB is picking the Messages from the Websphere MQ. As soon as the MDB picks the message on the OnMessage(), that Message is deleted from the MQ.
After the MDB picks the message am doing lot of businness logic and again i will put the message in Another MQ Queue(Say Out QUEUE).
But while am doing the Business logic in case of system failure or the server crashes. I lost that message. For this problem i have a plan of XA transactions.
But I dont know how to implement XA transactions in OC4J and MQ  |
|
Back to top |
|
 |
atheek |
Posted: Wed Sep 10, 2008 11:08 am Post subject: |
|
|
 Partisan
Joined: 01 Jun 2006 Posts: 327 Location: Sydney
|
Are you using container managed transaction with transaction attribute set to "required"? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 10, 2008 2:15 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
atheek wrote: |
Are you using container managed transaction with transaction attribute set to "required"? |
In fact for the MDB it should be "required new"  _________________ MQ & Broker admin |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 10, 2008 2:19 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
meetgaurav wrote: |
HI FJB_SAPER
I think Still U R not clear with my problem.
* WEBSPEHRE MQ
* OC4J where the MDB is deployed |
I think I am getting it:
JMS provider Websphere MQ
Application Server Oracle (OC4J)
meetgaurav wrote: |
Actually My MDB is picking the Messages from the Websphere MQ. As soon as the MDB picks the message on the OnMessage(), that Message is deleted from the MQ. |
Does not match what you're talking about transactionality support and using context.rollbackOnly()
meetgaurav wrote: |
After the MDB picks the message am doing lot of businness logic and again i will put the message in Another MQ Queue(Say Out QUEUE).
But while am doing the Business logic in case of system failure or the server crashes. I lost that message. For this problem i have a plan of XA transactions.
But I dont know how to implement XA transactions in OC4J and MQ  |
Check out my previous post and verify the J2EE transaction handling...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
meetgaurav |
Posted: Wed Sep 10, 2008 10:02 pm Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
Suppose If I add "Requires New" attribute. Then for Example
I have 10 Mesages in my Webphere MQ queue. While my MDB onMessage() processing the Messages after 5 messages while processing 6th message, If I called System.exit() Manually. Wat will happen?? Whether the 6th message will remain in the Queue.
I tryed in XA trsactions but is not working. 6th message is not in the Queue. Only able to get 7,8,9,10.
I lost the 6th Message.
Plz assist Me..  |
|
Back to top |
|
 |
meetgaurav |
Posted: Wed Sep 10, 2008 10:39 pm Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>MdbBean</ejb-name>
<method-name>onMessage</method-name>
<method-params>
<method-param>javax.jms.Message</method-param>
</method-params>
</method>
<trans-attribute>RequiresNew</trans-attribute>
</container-transaction>
</assembly-descriptor>
I added the above code in my ejb-jar.xml. After that I put 3 messages in my MQ after processing my first message and then while processing my second message I throwed a null pointer exception.
But my 2nd message is not in the Queue only 3rd is there. I lost the 2nd message here..
Please assist Me  |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Sep 11, 2008 2:33 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Your session should be created as follows:
QueueSession mysession = qconnection.createSession(true, Session.AUTO_ACKNOWLEDGE);
This is to enable transactionality at the session level.
In WAS the first attribute does not matter as it is overwritten by the Container's transactionality setting. You may HAVE to set it to true in OC4J as application server containers are known to behave differently.
For the rest, trial and error are your friends.
You should only see the message get consumed if the happy path goes over:
mysession.commit();
Also be careful when you exit with System.exit and make sure to use a different number from 0 which would indicate an exit with no problems.
Check the oracle OC4J restart log where something should be indicated about transactions in flight and make sure that the ORA team is not deleting them in order to bring the server back up.
Finally you may check the MQ server for transactions in flight using dspmqtrn... Those msgs may be in flight and not reachable. After the app server (OC4J) is back up and all in flight status has been processed check again with dspmqtrn. If messages remain at this point (same tranID) and the queue is empty you may have to resolve the status. Read more in the system admin guide on how to do this
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
meetgaurav |
Posted: Thu Sep 11, 2008 3:18 am Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
Hi FJB_SAPER
But I will never use this code in my project
QueueSession mysession = qconnection.createSession(true, Session.AUTO_ACKNOWLEDGE);
Queue connection factory and Queue names are in the OC4J deployment descriptor only. Not in my code.
My MDB onMessage() will pick the message directly. there is no session or connection factory in the code.. All in deployment descriptor only
If I have the session then I know this is very easy to implement.
Please assist Me how to proceed further |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Sep 11, 2008 3:26 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Well different app servers handle MDB's in different ways.
Read up on your OC4J manual about MDB's. I guess you'll get the 411 on AQ MDB's there. Your best bet for correct transactionality might be to use the MQ/AQ bridge and then deal with AQ only... or contact support and see if they can help you....
Our oracle team deals with messages through PL/SQL and AQ only. The MQ/AQ messaging gateway works fine for us.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|