JMS priority configuration through WL10.3 admin console
Issue:
How To prioritize the messages enqueued on a JMS queue.
Assigning the JMS priority of 9 (max) to some messages before enqueing them, the rest have default priority which is 4.
The destination (JMS queue) is configured not to override the message priorities (set to -1 which is default) assigned by the producer.
However, we dont see those messages with priority=9 being the first ones to be assigned to the MDB(Message Driven Beans).
All the messages are assigned to the MDBs in the order they were enqued.
Solution:
Need to create the destination Key for JMSPriority to make this work?
WebLogic JMSDestination does not do anything special with the JMSPriority header.
To make JMS priority work, you have to define a destination sort key to sort by priority so that higher priority messages are placed on the queue ahead of lower priority ones.
1.) In WLS Admin Console. Go the Services->Messaging->JMS Modules and either create a new module or select an existing one.
2.) Add a “system resource” to the module of type Destination Sort Key.
3.) Once you have created it, select it and modify the Sort Key to select JMSPriority.
4.) Next, select or create the queue in the same JMS Module.
5.) Once the queue exists, select it and pick your destination key and move it to the Chosen Panel.
Destination Keys
By default, WebLogic JMS destinations use first-in-first-out (FIFO) ordering. Simply put, the next message to be processed by a consumer will be the message that has been waiting in the destination the longest. WebLogic JMS also gives you the ability to use message headers or property values to sort messages in either ascending or descending order. To do this, you need to define one or more destination keys and associate these keys with a JMS destination, either directly or through the use of a template.
Any destination can have zero or more destination keys that control the ordering of messages in the destination.
By creating a descending order destination key on the JMSMessageID message header, we can configure a destination to use last-in-first-out (LIFO) ordering. By creating a destination key on the JMSPriority message header, we can configure a destination to use priority ordering where WebLogic JMS will process the highest priority messages first and use FIFO ordering for messages with the same priority.
It is important to note that using sorting orders other than FIFO or LIFO increases the overhead of sending a message. WebLogic JMS will have to scan some portion of the messages in a destination to determine where to place the incoming message. Though this is not a big deal for destinations with a small backlog of messages, it can be a huge performance penalty for destinations containing a large backlog of messages. Therefore, we recommend avoiding sorted destinations unless the price of not sorting the destination (for example, in increased application complexity) is higher than the cost of the potential performance degradation.
In most cases, the default FIFO sort order works best and will always give the best performance. You can change the sorting order to LIFO using the JMSMessageID without any significant performance penalty. Sorting destinations by any other property can cause significant performance degradation on the producer or the consumer. The amount of performance degradation will depend on the number of undelivered messages stored in the destination at any point in time.
Best Practice
FIFO or LIFO sort orders provide the best performance. Any other sorting order can cause significant performance degradation that will be proportional to the number of undelivered messages stored in the destination.
In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.
Hello,
Is it possible to add a destination key (JMSPriority) to an already existing queue already containing messages ?
Kind regards,
Edwin
Yes, you shall be able to…