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 » Priority queue message order problem in WAS MDB

Post new topic  Reply to topic
 Priority queue message order problem in WAS MDB « View previous topic :: View next topic » 
Author Message
bennytseng
PostPosted: Tue Jun 13, 2006 4:06 pm    Post subject: Priority queue message order problem in WAS MDB Reply with quote

Newbie

Joined: 13 Jun 2006
Posts: 1

Got a problem with the MDB message reading order under WAS 5.1. Wonder if anyone can shed some light.

The environment:
1. WebSphere Application Server v5.1.
2. WebSphere MQ v5.3
3. Created local queue with the property "Message Delivery Sequence" set to "Priority".
4. Created the necessary WebSphere MQ JMS Provider resources including the queue connection factory and queue destination.
5. For the queue destination resource, I left the "Priority" setting to "Application Defined", since my application programatically set the message priority.
5. Created a message listener port for the MDB listening on the queue.

My Java application creates two threads, one thread generating message at high priority (7) and the other one generating message at low pririty (3). The threads are long running and keep pumping out messages at regular intervals.

Now, my MDB is able to receive messages from the queue. However, the listener service is pulling messages off in the opposite order implied by the message priority. By examining my application output and monitoring through MQ explorer, I confirmed that it's the high priority messages that get stuck on the queue while the low priority messages are processed as fast as possible.

To confirm the problem is indeed related to the MDB, I wrote a simple Java application that including a loop doing blocking MQGET on the queue. This application works as expected, high prioirty messages get processed first.

Another thing I did is stopping the message listener port and then running my application, allowing the messages to be piled up on the queue. I then brought up the MQ explorer to examine the queue. All messages are placed in an order obeying the priority settings.

That makes me think that the MDB/message listener service is not processing according to the message priority.

I was able to examine the underlying MQ API calls made by the listener. It seems that the listener is using a sequence of MQGET with the MQGMO_BROWSE_FIRST/MQGMO_BROWSE_NEXT option. Looking up the MQ manual and I found the following:

If the queue has a MsgDeliverySequence of MQMDS_PRIORITY, and a message arrives on the queue that is of a higher priority than the one currently pointed to by the browse cursor, that message is not found during the current sweep of the queue using MQGMO_BROWSE_NEXT.
It can be found only after the browse cursor has been reset with MQGMO_BROWSE_FIRST (or by reopening the queue).

This seems to explain the problem I am seeing.

Has anyone hit a similar problem and/or tell me if this is a bug in WAS or a configuration/programming error on my side?

Thanks in advance.

Benny
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jun 13, 2006 6:22 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

This is a wild guess. I have no data to back it up.

Can you create two JMS destinations, one for your put and one for your get, that resolve to the same queue and have different Priority settings - app defined on the put and queue defined on the get?

Also, you could create a couple of instances of the MDB with different JMS Selectors that would read the different priorities...
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
lhotari
PostPosted: Wed Oct 25, 2006 10:36 pm    Post subject: NON.ASF.RECEIVE.TIMEOUT custom property on the Message Liste Reply with quote

Newbie

Joined: 25 Oct 2006
Posts: 5

"Non-ASF mode is enabled by setting the NON.ASF.RECEIVE.TIMEOUT custom property on the Message Listener Service, see WebSphere Application Server documentation for more details"


http://www-1.ibm.com/support/docview.wss?uid=swg21243169

Quote:

The standard ASF mode of MDB operation utilizes a queue browser to determine which message to deliver next. This works as expected if all messages are of the same priority, as new messages will be placed below the browse cursor, and will be processed as and when the browse cursor reaches it. However, if a high priority message arrives (of higher priority than the message currently being processed), then it will be placed above the message being browsed. This means that, contrary to expectations, the high priority message will not be processed next, and it may take up to 30 seconds for it to be picked up (the queue sweep timeout, how long the browser waits before scanning the queue from the start again).

A solution to this is to use the MDB in non-ASF mode. In this method of operation, the browser is not used, and instead each message is delivered using a receive() function. If a high priority message arrives on the queue, it is placed at the top, and the next time receive is called, it will read the first message off the queue, the high priority message. The drawback of this mode of operation is that the MDB operates single threaded, and that all Listener Ports/MDBs are affected. Non-ASF mode is enabled by setting the NON.ASF.RECEIVE.TIMEOUT custom property on the Message Listener Service, see WebSphere Application Server documentation for more details

Another possible solution is to change the message delivery sequence of the MQ queue from Priority to FIFO mode, so that messages are picked up in the order they arrive on the queue, irrespective of their priority. The drawback of this is that the priority is ignored. If it is likely to take longer than 30 seconds to process the messages on the queue when a high priority message arrives, then this method is counter-productive.
Back to top
View user's profile Send private message
lhotari
PostPosted: Tue Nov 21, 2006 7:42 am    Post subject: Websphere doesn't do backout handling in non-ASF mode Reply with quote

Newbie

Joined: 25 Oct 2006
Posts: 5

Websphere doesn't do backout handling in non-ASF mode. (at least for WAS 5.0.x) You'll have to write your own backout handling code. Redelivery works only for Container managed transactions in MDBs. (messageDrivenContext.setRollbackOnly(), see http://www.javaworld.com/javaworld/jw-02-2002/jw-0315-jms.html?page=3) You can fetch the delivery count with message.getIntProperty("JMSXDeliveryCount"). MQ specific backout handling example: http://www-304.ibm.com/jct09002c/isv/tech/sample_code/mq/backout.java
Back to top
View user's profile Send private message
imajit
PostPosted: Fri Mar 16, 2007 6:49 am    Post subject: Websphere MDB's not picking up high Priority messages Reply with quote

Newbie

Joined: 16 Mar 2007
Posts: 1

Is this the only solution to set ' NON.ASF.RECEIVE.TIMEOUT' on WAS Listeners to use Priority feature of Websphere MQ
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Priority queue message order problem in WAS MDB
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.