This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,889,825 Users
  • 2,269,775 Discussions


Using JMS priority field

jef_2802 Member Posts: 23
edited Sep 27, 2011 6:12AM in Java Message Service (JMS)

How to use Jms priority header field in JMS applications ?
How is it implemented by MOM ?
How will a consumer use this value ? If messages with different priorities are in a queue, what will be the result if a consuming application makes a simple call to get or receive or is listening on the queue (with MessageListener) ?
Is the result depending on the JMS provider implementation ?



  • EJP
    EJP Member Posts: 32,943 Gold Crown
    edited Sep 26, 2011 4:44PM
    It isn't documented?
  • Nigel Deakin-Oracle
    Nigel Deakin-Oracle Member Posts: 115
    edited Sep 27, 2011 5:41AM
    To set the priority when sending a message, use the following message on MessageProducer:

    void send(Message message, int deliveryMode, int priority, long timeToLive)
    Sends a message to the destination, specifying delivery mode, priority, and time to live.

    Alternatively you can set the default priority for a MessageProducer by calling
    setPriority(int defaultPriority)

    Note that the following method on Message is for a different purpose and hould not be used
    void setJMSPriority(int priority)

    The JMS 1.1 specification contains the following explanation of message priority.

    3.4.10 JMSPriority

    JMS defines a ten-level priority value, with 0 as the lowest priority and 9 as the
    highest. In addition, clients should consider priorities 0-4 as gradations of
    normal priority and priorities 5-9 as gradations of expedited priority.

    JMS does not require that a provider strictly implement priority ordering of
    messages; however, it should do its best to deliver expedited messages ahead
    of normal messages. Order of Message Sends

    • Messages of higher priority may jump ahead of previous lower-priority messages.
  • EJP
    EJP Member Posts: 32,943 Gold Crown
    Well exactly. @OP so what's the mystery again?
This discussion has been closed.