Results 1 to 3 of 3

Thread: About priority of message

  1. #1
    Join Date
    Nov 2012
    Posts
    18

    Default About priority of message

    Since currently rabbitmq not support the priority of message, i use separate queue for per priority-message. for example, queue.priority.low & queue.priority.high. And every queue has its respective listener, like this:
    Code:
      <rabbit:listener-container connection-factory="connectionFactory" message-converter="jsonMessageConverter"
          error-handler="rabbitErrorHandler" >
        <rabbit:listener queue-names="queue.priority.low" ref="messageConsumer" method="handleLowPriority" />
        <rabbit:listener queue-names="queue.priority.high" ref="messageConsumer" method="handleHighPriority" />
      </rabbit:listener-container>
    My question is:
    1 the instance of listenerContainer is equals to the instance of listener, is that correct? Since in above code i define two listener instance, so the instance of listenerContainer is aslo two.
    2 Since one listener can listening to more that one queue, so i want merge two listener into one:
    Code:
    <rabbit:listener queue-names="queue.priority.low, queue.priority.high" ref="messageConsumer" method="handleMessage" />
    But the question is ,how can i guarantee that queue.priority.high is always consuming before queue.priority.low, queue.priority.low is consumed only when queue.priority.high is empty?


    I noticed that in the class MessageProperties, there are a few properties that may be related to message priority:
    Code:
    public class MessageProperties {
        ...
        private static final Integer DEFAULT_PRIORITY = new Integer(0);
        private volatile Integer priority = DEFAULT_PRIORITY;
        ...
    }
    How can i use them?


    Any reply would be appreciated.
    Regards.
    Last edited by Wuaner; Jan 4th, 2013 at 03:58 AM.

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,015

    Default

    1. Yes; each listener element creates a listener container.
    2. No, a single container listening on multiple queues is NOT the same thing as having a separate container for each queue.There is no guarantee of order of processing messages (although you'd have to talk to the Rabbit guys about the exact broker algorithm used). Certainly, if there are currently no available consumers - because they are all processing a low priority message, any new high priority message won't be processed immediately.

    The property exists in the APIs, but Rabbit doesn't use it.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Nov 2012
    Posts
    18

    Default

    Thank you, Gary.

    The priority of message is very annoying indeed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •