Prioritizing the messages in JMS and MDB

Discussions

General J2EE: Prioritizing the messages in JMS and MDB

  1. Hi All,
    Can we prioritize the messages in JMS queue. My application needs to process one set of messages quickly tha the other messages. Even if there are 1000 messages in the queue when a high priority message comes in to the queue the Message Driven Bean should process it first. How can I prioritize such a thing in JMS. Is this feature supported. How do I go about ??

    Thanks,
    Vel
  2. Yes. You can give priorities to your messages.
    Every JMS message contains a standard set of header fields that is included by default and available to message consumers. Some fields can be set by the message producers.

    JMSPriority
     Specifies the priority level. This field is set before a message is sent.

    JMS defines ten priority levels, 0 to 9, 0 being the lowest priority. Levels 0-4 indicate gradations of normal priority, and level 5-9 indicate gradations of expedited priority.

    When the message is received, it contains the value specified by the method sending the message.

     I am not sure what app server you are using.. In case if it's BEA..check

    http://e-docs.bea.com/wls/docs81/jms/fund.html#1033981

    cheerz
    -vaheesan selvarajah
  3. Thank you vaheesan selvarajah. It was quite useful.

    Regards,
    vel
  4. Hi,

    Foe prioritizing if we just set the JMSPriority like below is it fine or we should also create some destination Keys. How to link the destination keys with the messages. It is not clear in the e-docs of weblogic.

    javax.jms.ObjectMessage message;
    javax.jms.QueueSession queueSession;

    //after initialising queue session

    message= queueSession.createObjectMessage();

    message.setJMSPriority(9);

    Thanks