ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » How to backout messages to queue on transaction rollback

Post new topic  Reply to topic Goto page 1, 2  Next
 How to backout messages to queue on transaction rollback « View previous topic :: View next topic » 
Author Message
tapak
PostPosted: Wed Mar 08, 2006 6:23 am    Post subject: How to backout messages to queue on transaction rollback Reply with quote

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
View user's profile Send private message
mvic
PostPosted: Wed Mar 08, 2006 6:27 am    Post subject: Re: How to backout messages to queue on transaction rollback Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

What version of MQ and CSD level please?
Back to top
View user's profile Send private message
tapak
PostPosted: Wed Mar 08, 2006 6:35 am    Post subject: Reply with quote

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
View user's profile Send private message
mvic
PostPosted: Wed Mar 08, 2006 6:49 am    Post subject: Reply with quote

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
View user's profile Send private message
tapak
PostPosted: Wed Mar 08, 2006 6:57 am    Post subject: Reply with quote

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
View user's profile Send private message
tapak
PostPosted: Thu Mar 09, 2006 11:35 am    Post subject: Reply with quote

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
View user's profile Send private message
mvic
PostPosted: Thu Mar 09, 2006 12:22 pm    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

OK so probably this is not the same as http://www.mqseries.net/phpBB2/viewtopic.php?t=27815
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Mar 09, 2006 1:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
tapak
PostPosted: Fri Mar 10, 2006 5:19 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri Mar 10, 2006 12:43 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
tapak
PostPosted: Fri Mar 10, 2006 1:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri Mar 10, 2006 1:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
tapak
PostPosted: Mon Mar 13, 2006 5:54 am    Post subject: Reply with quote

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
View user's profile Send private message
mvic
PostPosted: Mon Mar 13, 2006 6:09 am    Post subject: Reply with quote

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
View user's profile Send private message
bower5932
PostPosted: Tue Mar 14, 2006 2:31 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

This isn't JMS, but there is some code that does backing out at:

http://www-304.ibm.com/jct09002c/isv/tech/sampmq.html

You can look for backout.java. It might help you with what you are doing.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ Java / JMS » How to backout messages to queue on transaction rollback
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.