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 » Poison message handling in JMS, some more analysis

Post new topic  Reply to topic
 Poison message handling in JMS, some more analysis « View previous topic :: View next topic » 
Author Message
vininx
PostPosted: Tue Feb 08, 2011 10:32 pm    Post subject: Poison message handling in JMS, some more analysis Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Hi,
I am doing posion message handling in MQ JMS. I am trying to analyse how MQ JMS behaves in different scenarios of handling poison message. I am getting two different results in JMS based on the condition which I give. please find below my code snippet,

Code 1:-
--------
do
{
Message msg = qReceiver.receive (10000);

if (msg != null)
{
if (msg instanceof TextMessage)
{
msessge = (TextMessage) msg;
if (!isValidMessage (msessge))
{
System.out.println (">>> Poison message");
int boCount = msg.getIntProperty ("JMSXDeliveryCount");
System.out.println (">>> Back out count = " + boCount);
if (boCount >= BACKOUT_THRESHOLD)
{
System.out.println (">>> Backout limit exceeded ");
if (isBackoutQOpened ())
qSender.send (msg);
System.out.println (">>> Message moved to backout queue successfully");
commit ();
}
else
backout ();
}
else
{
System.out.println ("Message Received :" + message.getText ());
commit ();
msgCount--;
}
}
}
else
{
System.out.println (">>> No Messages available");
System.exit (1);
}
}while (msgCount > 0);

if I check as boCount >= BACKOUT_THRESHOLD, posion messages are moved to backout queue successfully,
Output:-
-------
>>> Message validation failed
>>> Poison message
>>> Back out count = 1
>>> Message validation failed
>>> Poison message
>>> Back out count = 2
>>> Message validation failed
>>> Poison message
>>> Back out count = 3
>>> Backout limit exceeded
>>> Message moved to backout queue successfully

Code2:-
------
I had changed the single condition from the above code as boCount > BACKOUT_THRESHOLD and in this case its reporting a different error as below,


Output:-
-------
$ java MQJMSReceiver 3 320
>>> Message validation failed
>>> Poison message
>>> Back out count = 1
>>> Message validation failed
>>> Poison message
>>> Back out count = 2
>>> Message validation failed
>>> Poison message
>>> Back out count = 3

Error Code: MQJMS1079
javax.jms.JMSException: MQJMS1079: Unable to write message to dead letter queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:622)
at com.ibm.mq.jms.MQMessageConsumer.deadLetter(MQMessageConsumer.java:4515)
at com.ibm.mq.jms.MQMessageConsumer.removeBadMessage(MQMessageConsumer.java:4776)
at com.ibm.mq.jms.MQMessageConsumer.getMessage(MQMessageConsumer.java:3615)
at com.ibm.mq.jms.MQMessageConsumer.receiveInternal(MQMessageConsumer.java:2856)
at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:2648)
at JMSReceiver.recvMessage(MQJMSReceiver.java:523)
at MQJMSReceiver.main(MQJMSReceiver.java:81)
javax.jms.JMSException: MQJMS1079: Unable to write message to dead letter queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:622)
at com.ibm.mq.jms.MQMessageConsumer.deadLetter(MQMessageConsumer.java:4515)
at com.ibm.mq.jms.MQMessageConsumer.removeBadMessage(MQMessageConsumer.java:4776)
at com.ibm.mq.jms.MQMessageConsumer.getMessage(MQMessageConsumer.java:3615)
at com.ibm.mq.jms.MQMessageConsumer.receiveInternal(MQMessageConsumer.java:2856)
at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:2648)
at JMSReceiver.recvMessage(MQJMSReceiver.java:523)
at MQJMSReceiver.main(MQJMSReceiver.java:81)
javax.jms.JMSException: MQJMS1079: Unable to write message to dead letter queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:622)
at com.ibm.mq.jms.MQMessageConsumer.deadLetter(MQMessageConsumer.java:4515)
at com.ibm.mq.jms.MQMessageConsumer.removeBadMessage(MQMessageConsumer.java:4776)
at com.ibm.mq.jms.MQMessageConsumer.getMessage(MQMessageConsumer.java:3615)
at com.ibm.mq.jms.MQMessageConsumer.receiveInternal(MQMessageConsumer.java:2856)
at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:2648)
at JMSReceiver.recvMessage(MQJMSReceiver.java:523)
at MQJMSReceiver.main(MQJMSReceiver.java:81)

The BACKOUT_THRESHOLD value here is 3 and when the receive() happenes for the 4th time, an exception occurs and MQ JMS is unable to write message in to dead letter queue(dont know why). Please let me know whether my inference is correct and also why it is showing such anamalous behavior.
What advise should I provide to an application to handle poison message correctly in their program.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Feb 09, 2011 5:05 am    Post subject: Re: Poison message handling in JMS, some more analysis Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

vininx wrote:
MQ JMS is unable to write message in to dead letter queue(dont know why)


There should be a linked exception that tells you why.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
vininx
PostPosted: Wed Feb 09, 2011 6:48 am    Post subject: Poison message handling in JMS, some more analysis Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Vitor,
Thanks for you reply. I get the below JMSLinked Exception as 2035,

Error Code: MQJMS1079
javax.jms.JMSException: MQJMS1079: Unable to write message to dead letter queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:622)
at com.ibm.mq.jms.MQMessageConsumer.deadLetter(MQMessageConsumer.java:4515)
at com.ibm.mq.jms.MQMessageConsumer.removeBadMessage(MQMessageConsumer.java:4776)
at com.ibm.mq.jms.MQMessageConsumer.getMessage(MQMessageConsumer.java:3615)
at com.ibm.mq.jms.MQMessageConsumer.receiveInternal(MQMessageConsumer.java:2856)
at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:2648)
at JMSReceiver.recvMessage(MQJMSReceiver.java:523)
at MQJMSReceiver.main(MQJMSReceiver.java:81)
javax.jms.JMSException: MQJMS1079: Unable to write message to dead letter queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:622)
at com.ibm.mq.jms.MQMessageConsumer.deadLetter(MQMessageConsumer.java:4515)
at com.ibm.mq.jms.MQMessageConsumer.removeBadMessage(MQMessageConsumer.java:4776)
at com.ibm.mq.jms.MQMessageConsumer.getMessage(MQMessageConsumer.java:3615)
at com.ibm.mq.jms.MQMessageConsumer.receiveInternal(MQMessageConsumer.java:2856)
at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:2648)
at JMSReceiver.recvMessage(MQJMSReceiver.java:523)
at MQJMSReceiver.main(MQJMSReceiver.java:81)
javax.jms.JMSException: MQJMS1079: Unable to write message to dead letter queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:622)
at com.ibm.mq.jms.MQMessageConsumer.deadLetter(MQMessageConsumer.java:4515)
at com.ibm.mq.jms.MQMessageConsumer.removeBadMessage(MQMessageConsumer.java:4776)
at com.ibm.mq.jms.MQMessageConsumer.getMessage(MQMessageConsumer.java:3615)
at com.ibm.mq.jms.MQMessageConsumer.receiveInternal(MQMessageConsumer.java:2856)
at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:2648)
at JMSReceiver.recvMessage(MQJMSReceiver.java:523)
at MQJMSReceiver.main(MQJMSReceiver.java:81)
JMS error codeMQJMS1079
JMS Linked Exception com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2035


So, is it the default behavior in JMS? (i,e MQ JMS will try to move the message into dead letter queue when receive happens even after exceeding backout threshold (May be MQ might check internally for every receive). But this is not happeneing when I check as boCount >= BACKOUT_THRESHOLD... Please advise...
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Feb 09, 2011 6:50 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

So MQRC 2035 means what?

What does the MQ JMS documentation say on how backout thresholds are handled?
Back to top
View user's profile Send private message
vininx
PostPosted: Wed Feb 09, 2011 7:02 am    Post subject: Poison message handling in JMS, some more analysis Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

I know that 2035 means MQRC_NOT_AUTHORIZED... MQ moves the message to dead letter queue if it is unable to move to backout queue. Do you find any reason why the >= condition worked successfully.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Feb 09, 2011 7:13 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/jm35205_.htm
Back to top
View user's profile Send private message
shashikanth_in
PostPosted: Thu Feb 10, 2011 12:34 am    Post subject: Reply with quote

Centurion

Joined: 26 Feb 2009
Posts: 123

Have you checked max queue depth of BOQ? It might be that when you tried >=, it exceeded max queue depth of BOQ and JMS is trying to put the message to DLQ and fails.
Back to top
View user's profile Send private message
vininx
PostPosted: Thu Feb 10, 2011 4:28 am    Post subject: Poison message handling in JMS, some more analysis Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Shasi,
My backout queue has a queue depth of 10k so, I believe thats not the reason. Here MQ JMS is trying to put message to the SYSTEM.DEAD.LETTER.QUEUE and my id doesnt have put access for that to succeed so I am getting 2035 reason code.
Back to top
View user's profile Send private message
fatherjack
PostPosted: Thu Feb 10, 2011 5:55 am    Post subject: Re: Poison message handling in JMS, some more analysis Reply with quote

Knight

Joined: 14 Apr 2010
Posts: 522
Location: Craggy Island

vininx wrote:
Shasi,
My backout queue has a queue depth of 10k so, I believe thats not the reason. Here MQ JMS is trying to put message to the SYSTEM.DEAD.LETTER.QUEUE and my id doesnt have put access for that to succeed so I am getting 2035 reason code.


So why not fix the 2035 then the message will get put to the DLQ with a dead letter reason. That'll then tell you why it couldn't be put to the BOQ.
_________________
Never let the facts get in the way of a good theory.
Back to top
View user's profile Send private message
vininx
PostPosted: Thu Feb 10, 2011 6:21 am    Post subject: Poison message handling in JMS, some more analysis Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Yes, I am currently doing that. I am getting in touch with my MQ admin to fix 2035 issue and after that I need to analyse the dead letter header. Thanks for all your response.
Back to top
View user's profile Send private message
ChristianH
PostPosted: Thu Feb 10, 2011 7:46 am    Post subject: Reply with quote

Novice

Joined: 27 Sep 2007
Posts: 19
Location: London, UK

Hi,

just a thing I was wondering when I was reading this thread:
Is the "Backout Requeue Name" attribute on your queue set?

I think I read somewhere that JMS is handling the put to a backoutqueue for you. So you should need to code this yourself.

I believe that your message is going (or is tried to being moved) to the dead letter queue, because the backout requeue name might not be set.
Back to top
View user's profile Send private message
vininx
PostPosted: Thu Feb 10, 2011 8:05 am    Post subject: Poison message handling in JMS, some more analysis Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Please find below the display of my source queue and backout queue

Source queue:-
----------------
display queue(MQSBNY.MQSBNY.BMW.BMW.TMPROXY_SOL_JMS)
1 : display queue(MQSBNY.MQSBNY.BMW.BMW.TMPROXY_SOL_JMS)
AMQ8409: Display Queue details.
QUEUE(MQSBNY.MQSBNY.BMW.BMW.TMPROXY_SOL_JMS)
TYPE(QLOCAL) ACCTQ(QMGR)
ALTDATE(2010-12-21) ALTTIME(05.21.39)
** BOQNAME(MQSBNY.MQSBNY.BMW.BMW.TMPROXY_SOL_JAVA_U) **
BOTHRESH(3) CLUSNL( )
CLUSTER( ) CLWLPRTY(0)
CLWLRANK(0) CLWLUSEQ(QMGR)
CRDATE(2009-11-13) CRTIME(13.17.03)
CURDEPTH(2) DEFBIND(OPEN)
DEFPRTY(0) DEFPSIST(YES)
DEFSOPT(SHARED) DEFTYPE(PREDEFINED)
DESCR(RYJ1396 MSGS SENT TO TM PROXY (JMS))
DISTL(NO) GET(ENABLED)
HARDENBO INITQ( )
IPPROCS(0) MAXDEPTH(10000)
MAXMSGL(100000) MONQ(QMGR)
MSGDLVSQ(FIFO) NOTRIGGER
NPMCLASS(NORMAL) OPPROCS(0)
PROCESS( ) PUT(ENABLED)
QDEPTHHI(60) QDEPTHLO(20)
QDPHIEV(ENABLED) QDPLOEV(DISABLED)
QDPMAXEV(ENABLED) QSVCIEV(HIGH)
QSVCINT(900000) RETINTVL(999999999)
SCOPE(QMGR) SHARE
STATQ(QMGR) TRIGDATA( )
TRIGDPTH(1) TRIGMPRI(0)
TRIGTYPE(NONE) USAGE(NORMAL)


Backout Queue:-
----------------------
display queue(MQSBNY.MQSBNY.BMW.BMW.TMPROXY_SOL_JAVA_U)
2 : display queue(MQSBNY.MQSBNY.BMW.BMW.TMPROXY_SOL_JAVA_U)
AMQ8409: Display Queue details.
QUEUE(MQSBNY.MQSBNY.BMW.BMW.TMPROXY_SOL_JAVA_U)
TYPE(QLOCAL) ACCTQ(QMGR)
ALTDATE(2007-11-2 ALTTIME(16.15.51)
BOQNAME( ) BOTHRESH(3)
CLUSNL( ) CLUSTER( )
CLWLPRTY(0) CLWLRANK(0)
CLWLUSEQ(QMGR) CRDATE(2007-11-2
CRTIME(16.15.51) CURDEPTH(0)
DEFBIND(OPEN) DEFPRTY(0)
DEFPSIST(YES) DEFSOPT(SHARED)
DEFTYPE(PREDEFINED)
DESCR(RCX1098 MSGS SENT TO TM PROXY (JAVA) NON-PRIV Q)
DISTL(NO) GET(ENABLED)
HARDENBO INITQ( )
IPPROCS(0) MAXDEPTH(10000)
MAXMSGL(100000) MONQ(QMGR)
MSGDLVSQ(FIFO) NOTRIGGER
NPMCLASS(NORMAL) OPPROCS(0)
PROCESS( ) PUT(ENABLED)
QDEPTHHI(60) QDEPTHLO(20)
QDPHIEV(ENABLED) QDPLOEV(DISABLED)
QDPMAXEV(ENABLED) QSVCIEV(HIGH)
QSVCINT(900000) RETINTVL(999999999)
SCOPE(QMGR) SHARE
STATQ(QMGR) TRIGDATA( )
TRIGDPTH(1) TRIGMPRI(0)
TRIGTYPE(NONE) USAGE(NORMAL)

.bindings file:-
---------------
$ cat .bindings
#This file is used by the JNDI FSContext.
#Thu Feb 10 10:14:59 EST 2011
TESTQCF/RefAddr/21/Encoding=String
TESTQCF/FactoryName=com.ibm.mq.jms.MQQueueConnectionFactoryFactory
TESTQCF/RefAddr/8/Encoding=String
TESTQCF/RefAddr/22/Type=MRET
BOQUEUE/RefAddr/4/Type=CCS
BOQUEUE/RefAddr/3/Encoding=String
TESTQUEUE/RefAddr/9/Content=SQT3
TESTQCF/RefAddr/7/Type=CT
TESTQUEUE/RefAddr/7/Content=1
BOQUEUE/RefAddr/5/Encoding=String
TESTQCF/RefAddr/10/Encoding=String
TESTQCF/RefAddr/18/Type=TCM
TESTQUEUE/RefAddr/5/Content=0
TESTQUEUE/RefAddr/7/Type=FIQ
TESTQCF/RefAddr/13/Content=5000
BOQUEUE/RefAddr/7/Encoding=String
TESTQCF/RefAddr/12/Encoding=String
TESTQCF/RefAddr/1/Type=TRAN
TESTQCF/RefAddr/11/Content=false
TESTQUEUE/RefAddr/0/Encoding=String
TESTQCF/RefAddr/22/Content=1
TESTQCF/RefAddr/14/Encoding=String
TESTQCF/RefAddr/12/Type=UCP
TESTQUEUE/RefAddr/1/Type=EXP
TESTQCF/RefAddr/20/Content=SYSTEM.DEFAULT.MODEL.QUEUE
TESTQCF/RefAddr/8/Content=0
BOQUEUE/RefAddr/5/Type=TC
TESTQCF/RefAddr/6/Content=819
TESTQCF/RefAddr/8/Type=CTO
TESTQCF/RefAddr/4/Content=1414
TESTQUEUE/RefAddr/3/Content=-2
TESTQCF/RefAddr/19/Type=MNST
TESTQUEUE/RefAddr/8/Type=QU
BOQUEUE/RefAddr/9/Encoding=String
TESTQUEUE/RefAddr/1/Content=-2
BOQUEUE/RefAddr/8/Content=BMW.BMW.TMPROXY_SOL_JAVA_U
TESTQCF/RefAddr/1/Encoding=String
TESTQCF/RefAddr/2/Type=QMGR
TESTQUEUE/RefAddr/2/Encoding=String
BOQUEUE/RefAddr/6/Content=273
TESTQCF/RefAddr/16/Encoding=String
TESTQCF/RefAddr/13/Type=PINT
TESTQCF/RefAddr/3/Encoding=String
TESTQUEUE/RefAddr/2/Type=PRI
TESTQUEUE/RefAddr/4/Encoding=String
BOQUEUE/ClassName=com.ibm.mq.jms.MQQueue
TESTQCF/RefAddr/18/Encoding=String
TESTQCF/RefAddr/5/Encoding=String
BOQUEUE/RefAddr/6/Type=ENC
TESTQUEUE/RefAddr/6/Encoding=String
TESTQCF/RefAddr/2/Content=SQT3
TESTQCF/RefAddr/9/Type=SRC
TESTQUEUE/RefAddr/8/Encoding=String
TESTQCF/RefAddr/0/Content=6
BOQUEUE/RefAddr/0/Type=VER
TESTQCF/ClassName=com.ibm.mq.jms.MQQueueConnectionFactory
TESTQUEUE/RefAddr/9/Type=QMGR
TESTQCF/RefAddr/18/Content=true
TESTQCF/RefAddr/3/Type=HOST
BOQUEUE/RefAddr/4/Content=1208
TESTQCF/RefAddr/16/Content=
BOQUEUE/RefAddr/2/Content=-2
TESTQCF/RefAddr/14/Type=MBS
TESTQUEUE/RefAddr/3/Type=PER
BOQUEUE/RefAddr/0/Encoding=String
TESTQCF/RefAddr/20/Encoding=String
BOQUEUE/RefAddr/0/Content=6
TESTQCF/RefAddr/7/Encoding=String
BOQUEUE/RefAddr/7/Type=FIQ
BOQUEUE/RefAddr/2/Encoding=String
TESTQCF/RefAddr/22/Encoding=String
TESTQCF/RefAddr/9/Encoding=String
BOQUEUE/RefAddr/4/Encoding=String
TESTQUEUE/RefAddr/8/Content=BMW.BMW.TMPROXY_SOL_JMS
BOQUEUE/RefAddr/1/Type=EXP
TESTQUEUE/RefAddr/6/Content=273
BOQUEUE/RefAddr/6/Encoding=String
TESTQCF/RefAddr/14/Content=10
TESTQCF/RefAddr/4/Type=PORT
TESTQCF/RefAddr/11/Encoding=String
TESTQCF/RefAddr/12/Content=true
TESTQCF/RefAddr/15/Type=FIQ
TESTQUEUE/RefAddr/4/Type=CCS
TESTQCF/RefAddr/13/Encoding=String
TESTQCF/RefAddr/10/Content=false
TESTQCF/RefAddr/21/Content=
BOQUEUE/FactoryName=com.ibm.mq.jms.MQQueueFactory
BOQUEUE/RefAddr/8/Type=QU
TESTQCF/RefAddr/15/Encoding=String
TESTQCF/RefAddr/9/Content=0
TESTQUEUE/FactoryName=com.ibm.mq.jms.MQQueueFactory
TESTQCF/RefAddr/7/Content=\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
\u0000\u0000
TESTQCF/RefAddr/20/Type=TM
TESTQCF/RefAddr/5/Content=SYSTEM.DEF.SVRCONN
BOQUEUE/RefAddr/2/Type=PRI
TESTQUEUE/RefAddr/4/Content=1208
BOQUEUE/RefAddr/8/Encoding=String
TESTQUEUE/ClassName=com.ibm.mq.jms.MQQueue
TESTQCF/RefAddr/5/Type=CHAN
TESTQUEUE/RefAddr/2/Content=-2
TESTQCF/RefAddr/0/Encoding=String
BOQUEUE/RefAddr/9/Content=SQT3
TESTQUEUE/RefAddr/1/Encoding=String
TESTQUEUE/RefAddr/0/Content=6
TESTQCF/RefAddr/16/Type=LA
BOQUEUE/RefAddr/7/Content=1
TESTQUEUE/RefAddr/5/Type=TC
TESTQCF/RefAddr/2/Encoding=String
TESTQUEUE/RefAddr/3/Encoding=String
BOQUEUE/RefAddr/5/Content=0
TESTQCF/RefAddr/17/Encoding=String
BOQUEUE/RefAddr/9/Type=QMGR
TESTQCF/RefAddr/4/Encoding=String
TESTQCF/RefAddr/10/Type=SFIPS
TESTQUEUE/RefAddr/5/Encoding=String
TESTQCF/RefAddr/19/Encoding=String
TESTQCF/RefAddr/3/Content=localhost
TESTQCF/RefAddr/21/Type=TQPFX
TESTQCF/RefAddr/6/Encoding=String
TESTQUEUE/RefAddr/7/Encoding=String
BOQUEUE/RefAddr/3/Type=PER
TESTQCF/RefAddr/1/Content=0
TESTQCF/RefAddr/6/Type=CCS
TESTQCF/RefAddr/19/Content=true
TESTQUEUE/RefAddr/9/Encoding=String
TESTQCF/RefAddr/17/Type=RINT
TESTQCF/RefAddr/17/Content=5000
TESTQUEUE/RefAddr/6/Type=ENC
BOQUEUE/RefAddr/3/Content=-2
TESTQCF/RefAddr/0/Type=VER
TESTQCF/RefAddr/15/Content=1
BOQUEUE/RefAddr/1/Content=-2
TESTQCF/RefAddr/11/Type=SPAG
BOQUEUE/RefAddr/1/Encoding=String
TESTQUEUE/RefAddr/0/Type=VER

receive method:-
------------------
Code:
public void recvMessage (int msgCount)
    {
        if (this.qReceiver != null)
        {
            TextMessage msessge = null;
            try
            {
               do
               {
                    Message msg = qReceiver.receive (10000);

                    if (msg != null)
                    {
                         if (msg instanceof TextMessage)
                         {
                              msessge = (TextMessage) msg;
                              if (!isValidMessage (msessge))
                              {
                                   System.out.println (">>> Poison message");
                                   int boCount   = msg.getIntProperty ("JMSXDeliveryCount");
                                   System.out.println (">>> Back out count = " + boCount);
                                   if (boCount >  BACKOUT_THRESHOLD)
                                   {
                                       System.out.println (">>> Backout limit exceeded ");
                                       if (isBackoutQOpened ())
                                             qSender.send (msg);
                                       System.out.println (">>> Message moved to backout queue successfully");
                                       commit ();
                                   }
                                   else
                                   {
                                          backout ();
                                   }
                              }
                              else
                              {
                                System.out.println ("Message Received :" + message.getText ());
                                commit ();
                                msgCount--;
                              }
                         }
                   }
                   else
                   {
                         System.out.println (">>> No Messages available");
                         System.exit (1);
                   }
               }while (msgCount > 0);

            }
            catch (JMSException jmsEx)
            {
                report ("Failed to receive messages due to internal error", jmsEx);
                jmsEx.printStackTrace ();
                System.out.println ("JMS error code" + jmsEx.getErrorCode ());
                System.out.println ("JMS Linked Exception " + jmsEx.getLinkedException ());
                closeSession ();
                endConnection ();
                System.exit (1);
            }
        }
        else
            report ("Destination QueueReceiver is not available", null);
    }


output:-
--------
$ java MQJMSReceiver 2 320
>>> Message validation failed
>>> Poison message
>>> Back out count = 1
>>> Message validation failed
>>> Poison message
>>> Back out count = 2
>>> Message validation failed
>>> Poison message
>>> Back out count = 3
>>> Message validation failed
>>> Poison message
>>> Back out count = 1
>>> Message validation failed
>>> Poison message
>>> Back out count = 2
>>> Message validation failed
>>> Poison message
>>> Back out count = 3

Status:-
--------
The 2035 issue is solved, but still the message is there in the source queue and when bcount > BACKOUT_THRESHOLD is reached, nothing gets printed.
Back to top
View user's profile Send private message
ChristianH
PostPosted: Thu Feb 10, 2011 8:09 am    Post subject: Reply with quote

Novice

Joined: 27 Sep 2007
Posts: 19
Location: London, UK

Does the JMS application have the sufficient authority to put to the backout queue?


:edit:
Sorry, it should have, I guess as you could put it coded by your application before... unless the Listener uses a different authorisation than the actual application...?

What do you mean by nothing gets printed?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Feb 10, 2011 9:25 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Quote:
Code:
                                   if (boCount >  BACKOUT_THRESHOLD)
                                   {
                                       System.out.println (">>> Backout limit exceeded ");
                                       if (isBackoutQOpened ())
                                             qSender.send (msg);
                                       System.out.println (">>> Message moved to backout queue successfully");
                                       commit ();
                                   }
                                   else
                                   {
                                          backout ();
                                   }


You did not show the commit() or backout() methods your are calling there. What I did not see is if you are deviating in any way from the session.commit() or session.rollback() methods and what else you might be doing there...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Poison message handling in JMS, some more analysis
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.