Reputation: 1
Requirement: I need my message-driven bean (MDB) to be able to read from four different JMS queues and MDB should read the messages based on Queue’s priority.
Say - I have 4 JMS Queue A, B, C and D with priority 8(Highest), 7, 6 and 5 respectively. So, if queue C has 500 messages in it, while queue A and B are empty. My MDB should consume messages from queue C. But the moment that I receive a message in higher priority queue (A or B), my MDB should stop reading from C, and consume a message from the higher priority queue (till the queue is empty), then continue consuming from the lower priority queue.
Setting Done: I am using WebSphere 7.0 and have set the JMS Queues’s priority in admin console properly.
Advanced Properties
*Priority : Specified
Specified priority : 8*
Problem: But still my MDB fails to read as expected. What are more configuration required to achieve my requirement.
Please do the needful. Thanks in advance.
Upvotes: 0
Views: 818
Reputation: 18050
For your scenario you just need one queue, and put messages with different priorities to the queue. MDB will read messages according to the priorities. Do not set any priority in the queue settings in WebSphere, but your application must set priority correctly while putting message in the queue. MDB can listen on single queue only.
Upvotes: 0
Reputation: 1600
An MDB is only driven from a single queue at any one time. The messages from that queue will be consumed in priority order. The priority set on the queue is the default priority of messages if a priority is not given when the message is sent.
So it's not going to be possible to have a MDB move between a set of queues.
If you want a single consumer to always be getting the highest priority messages you'll need a single queue and a single MDB. Alternatively create multiple queues and split the messages among them - with different MDBs handling different priorities
Upvotes: 0