问题
I am a beginner in using spring camel rabbitmq
.
I am able to set message priority in message header by setting it in exchange out headers on the producer side, like this :
exchange.getOut().setHeader("rabbitmq.PRIORITY", 1);
BUT while consuming the messages they dont come in there order of priority. HELP !!
I can see in web interface of rabbitmq
that priority header in appropriately set
回答1:
Please carefully read the "Interaction with consumers" section of this document. You should also search for an answer on the RabbitMQ Users List or post your question there if it has not been asked.
回答2:
got the issue.
problem was that I was not able to set x-max-priority using camel
endpoints.
Need to add it in queueArgsConfigurer option in queue.
To do this we need to implement ArgsConfigurer interface like this :
@Component(value="QueueArgsConfigurer")
public class QueueArgsConfigurer implements ArgsConfigurer {
@Override
public void configurArgs(Map<String, Object> map) {
map.put("x-max-priority", 3);
}
}
And add to queue endpoint queueArgsConfigurer option like this:
queueArgsConfigurer=#QueueArgsConfigurer
Since I am using spring
I get the QueueArgsConfigurer by its bean name.
来源:https://stackoverflow.com/questions/44582445/unable-to-get-message-in-priority-sequence-spring-camel-rabbitmq