views:

190

answers:

2

I have a message driven bean that throws exception under certain conditions. When it throws an exception the message is not processed and put back on the queue. From what I understand with MQ and WAS (Websphere Application Server) the message should be marked as bad after x number of tries and removed from the queue. This is not happening and the message remains on the queue marked as bad.

What part of the configuration in MQ and/or WAS have I missed to set correct?

(The issue with the MDB throwing exceptions is NOT the point here)

Thanks.

+2  A: 

On the queue there are attributes BOQNAME and BOQTHRESH. These must be set to the name of the backout queue where the message is to be requeued and the threshold for number of backouts before requeueing the message.

In addition, the QMgr must be able to put the message onto the designated queue. Problems may include misspelling of the queue name, the backout queue being full or the account running the MDB was not authorized to put messages on the backout queue.

If the MDB detects a poison message loop and has nowhere to requeue the message, it stops processing. You will still see the thread but you will be missing one or more open input handles on the queue. The app must be restarted to revive it in this instance.

Avoid using the system's DLQ for the backout destination. The DLQ is where the QMgr will place messages arriving from another QMgr which cannot resolve to a destination queue. These will have a Dead Letter Header attached whereas MDB messages that are requeued will not. This can cause problems with any automation you have watching the DLQ. Therefore, it is advisable to have an exception queue per application that is not the DLQ.

BOQTHRESH should be greater than 1 or 2 because normal operations such as shutdown of the QMgr or channel can result in a backout. I generally set BOQTHRESH to 5 or 10 but have seen people set this much higher. Depends on your tolerance for retries and whether the backouts are typically caused by transient conditions such as filling up log extents.

T.Rob
This works great! Thanks. Follow up question (or should I ask it as a new question): What strategy should one have regarding this and listener ports? If the listener ports stops after less amount than the BOQ the messages will queue up.
Don't tempt me with "new question" offers since I'm becoming a reputation-whore! ;-)You are correct that whatever you set BOQTHRESH to *must* be lower than your retries as configured in the app server. Since I always set BOQTHRESH to something like 5 this is usually not a problem but then again, I tend to forget to mention it explicitly. Set retries up but not extremely high because you don't want to bog down the app server or QMgr if someone forgets to set BOQTHRESH and BOQNAME.
T.Rob
+1  A: 

Look at this How WebSphere handles poison messages article.
It applies to WAS 5, but the principles have not changed.

Romain Hippeau
There's some good info there about setting the MDB properties but the advice of using the system DLQ is a problem. Definitely use an app-specific backout queue and leave the system DLQ to the QMgr for its own uses. In addition to the problem of DLQ headers, QMgrs are increasingly shared resources. Many customers have had problems with one app's support team deleting another app's DLQ messages. Using app-specific backout queues eliminates this type of negative interaction.
T.Rob
@T.Rob I agree with not using DLQ as the backout queue. Instead use an error queue to backout to.
Romain Hippeau