Author |
Message
|
tapak |
Posted: Wed Mar 08, 2006 6:23 am Post subject: How to backout messages to queue on transaction rollback |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
I am having a message driven bean listening to a local queue. Message driven bean(MDB) process the message in a 2 phase transaction. Whenever the transaction fails ,the messages is backed out to the same input queue again and the MDB is invoked infinite times . I specified the retry limit to 3 for the listener port and also specified a backout queue for the listener queue with a backout count of 2 .This doesnt seems to work . Transaction is Bean managed . Any advice ? _________________ IBM Certified Solution Designer -- WebSphere MQ V5.3
IBM Certified Solution Designer -- WebSphere Business Integration - Message Broker V5
IBM Certified Specialist -- IBM WebSphere App Svr Advd Single Svr Ed. for Multiplatforms (Java) |
|
Back to top |
|
 |
mvic |
Posted: Wed Mar 08, 2006 6:27 am Post subject: Re: How to backout messages to queue on transaction rollback |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
What version of MQ and CSD level please? |
|
Back to top |
|
 |
tapak |
Posted: Wed Mar 08, 2006 6:35 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
Name: WebSphere MQ
Version: 530
CMVC level: p000-L021011
BuildType: IKAP - (Production) |
|
Back to top |
|
 |
mvic |
Posted: Wed Mar 08, 2006 6:49 am Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
tapak wrote: |
Name: WebSphere MQ
Version: 530
CMVC level: p000-L021011
BuildType: IKAP - (Production) |
Symptoms look similar to http://www.mqseries.net/phpBB2/viewtopic.php?t=27815
Please consider putting the latest patches on (CSD12). Your system is running code about 3.5 years old. Lots of problems have been found and fixed since then. |
|
Back to top |
|
 |
tapak |
Posted: Wed Mar 08, 2006 6:57 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
Thank you for the input . I will try deploying the application in our development server which is in CSD4 level and see if it helps . Also parallely request the admin group to install CSD12 . _________________ IBM Certified Solution Designer -- WebSphere MQ V5.3
IBM Certified Solution Designer -- WebSphere Business Integration - Message Broker V5
IBM Certified Specialist -- IBM WebSphere App Svr Advd Single Svr Ed. for Multiplatforms (Java) |
|
Back to top |
|
 |
tapak |
Posted: Thu Mar 09, 2006 11:35 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
The problem was with my code . I hard coded the jndiName in the common class which puts the message to the inputqueue. So even though on rollback , I try to put the message to the error queue , it was actually putting it to the input queue again causing the message driven bean to be invoked continously . How do I get the MDB to rollback the message to the backout queue after 2 attempts. Currently it is not rolling back even though the transaction is failing . _________________ IBM Certified Solution Designer -- WebSphere MQ V5.3
IBM Certified Solution Designer -- WebSphere Business Integration - Message Broker V5
IBM Certified Specialist -- IBM WebSphere App Svr Advd Single Svr Ed. for Multiplatforms (Java) |
|
Back to top |
|
 |
mvic |
Posted: Thu Mar 09, 2006 12:22 pm Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 09, 2006 1:11 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
tapak wrote: |
The problem was with my code . I hard coded the jndiName in the common class which puts the message to the inputqueue. So even though on rollback , I try to put the message to the error queue , it was actually putting it to the input queue again causing the message driven bean to be invoked continously . How do I get the MDB to rollback the message to the backout queue after 2 attempts. Currently it is not rolling back even though the transaction is failing . |
Assumption 1) you are not running in WAS (Websphere Application Server) The rollback to the backout queue / DLQ is automatic. (The MDB implementation handles it)
Assumption 2) you need to do this yourself.
You can rollback for count until x
When your redelivery count is x, before you touch any resource other than MQ, move (put) the message to the backout queue and exit the MDB on a commit. Resume normal processing on the next message.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
tapak |
Posted: Fri Mar 10, 2006 5:19 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
In my case ,it is not rolling back to the error queue on calling usertransaction.rollback. After rollback I am putting the contents in the message to an error queue . _________________ IBM Certified Solution Designer -- WebSphere MQ V5.3
IBM Certified Solution Designer -- WebSphere Business Integration - Message Broker V5
IBM Certified Specialist -- IBM WebSphere App Svr Advd Single Svr Ed. for Multiplatforms (Java) |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Mar 10, 2006 12:43 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
tapak wrote: |
In my case ,it is not rolling back to the error queue on calling usertransaction.rollback. After rollback I am putting the contents in the message to an error queue . |
You CANNOT rollback to a DIFFERENT queue. You can only move the message to a different queue on commit.
Rollback means that the message was never consumed and any action taken is being backed out. So the message is still in your input queue.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
tapak |
Posted: Fri Mar 10, 2006 1:12 pm Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
fjb_saper ,
I was expecting the same . On calling ut.rollback ,it should roll back the message to the input queue . and the mdb will be invoked again till the no of retries limit is reached . And I thought it was doing that earlier. But I finally I identified that the putMessage(Serializable obj, errorq) I was calling after ut.rollback was putting the message to the input queue instead of error queue as I hardcoded the inputq name in the putMessage method . Finally I found the mistake and removed the hardcoded value . After that it was putting the data from the input message to the input queue . Here is the code for bean managed transaction . Is it because I am using bean managed transaction . Thanks for your inputs.
try {
ut =
(UserTransaction) myCntxt.lookup(
"java:comp/UserTransaction");
ut.begin();
mpsom.submitChangeOrder(somd);
m_LogMgr.logMessage(
LogManager.LOG_EVENT,
"After Submit Change Order ",
"userid",
10,
2);
ut.commit();
} catch (Exception ex) {
ut.rollback();
ex.printStackTrace();
System.out.println("Rolling back transaction");
jmm = new JMSMsgManager(m_bussContext1,m_FTCuserContext1);
System.out.println("errorqjndi is " + errorqjndi);
jmm.putJMSMessage(somd,errorqjndi, false);
System.out.println("After putting to Error Q");
throw ex;
} _________________ IBM Certified Solution Designer -- WebSphere MQ V5.3
IBM Certified Solution Designer -- WebSphere Business Integration - Message Broker V5
IBM Certified Specialist -- IBM WebSphere App Svr Advd Single Svr Ed. for Multiplatforms (Java) |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Mar 10, 2006 1:37 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
well you seem to have some logic errors
in brief
Code: |
try{
ut.begin()
//read the message delivery count off the msg
if (count > acceptable ){
sender.send(msg, backoutq)
}else{
//do some process
}//endif
ut.commit()
}catch (Exception ex){
ut.rollback()
//log exception and linked exception if JMSE
}finally{
//release unneeded resources
} |
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
tapak |
Posted: Mon Mar 13, 2006 5:54 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
fjb_saper ,
Thank you for the input . What is the best way to get the backout count . Should we use the MQInquiry in MQ API or there is some other way to do this .
Second thing is that on rollback ,it is not rolling back the message to the input queue . I am running WAS5.1 and MQ 5.3 . Any thoughts ?
Thanks, Deepak _________________ IBM Certified Solution Designer -- WebSphere MQ V5.3
IBM Certified Solution Designer -- WebSphere Business Integration - Message Broker V5
IBM Certified Specialist -- IBM WebSphere App Svr Advd Single Svr Ed. for Multiplatforms (Java) |
|
Back to top |
|
 |
mvic |
Posted: Mon Mar 13, 2006 6:09 am Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
tapak wrote: |
What is the best way to get the backout count |
BackoutCount is a property of the message. Best way to find the answer to this question is, for example:
* Search the infocenter for backoutcount
* Search the infocenter for JMSXDeliveryCount
The infocenter is at http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Mar 14, 2006 2:31 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
|
Back to top |
|
 |
|