3 Replies Latest reply: Sep 27, 2011 5:12 AM by EJP RSS

    Using JMS priority field

    jfk
      Hi,

      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 ?

      Thanks
        • 1. Re: Using JMS priority field
          EJP
          It isn't documented?
          • 2. Re: Using JMS priority field
            Nigeldeakin-Oracle
            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.

            4.4.10.2 Order of Message Sends

            • Messages of higher priority may jump ahead of previous lower-priority messages.
            • 3. Re: Using JMS priority field
              EJP
              Well exactly. @OP so what's the mystery again?