Announcement Announcement Module
Collapse
No announcement yet.
About priority of message Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 03:58 AM.

  • #2
    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.

    Comment


    • #3
      Thank you, Gary.

      The priority of message is very annoying indeed.

      Comment

      Working...
      X