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:
My question is: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>
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: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?Code:<rabbit:listener queue-names="queue.priority.low, queue.priority.high" ref="messageConsumer" method="handleMessage" />
I noticed that in the class MessageProperties, there are a few properties that may be related to message priority:
How can i use them?Code:public class MessageProperties { ... private static final Integer DEFAULT_PRIORITY = new Integer(0); private volatile Integer priority = DEFAULT_PRIORITY; ... }
Any reply would be appreciated.
Regards.


Reply With Quote