无法按优先顺序获取消息Spring骆驼rabbitmq

无法按优先顺序获取消息Spring骆驼rabbitmq

本文介绍了无法按优先顺序获取消息Spring骆驼rabbitmq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用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 !!

我可以在rabbitmq的Web界面中看到适当设置的优先级标头

I can see in web interface of rabbitmq that priority header in appropriately set

推荐答案

忘记了问题.问题是我无法使用camel端点设置 x-max-priority .需要在队列的 queueArgsConfigurer 选项中添加它.为此,我们需要实现ArgsConfigurer接口,如下所示:

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);
}

}

并添加到队列终结点中的queueArgsConfigurer选项,如下所示: queueArgsConfigurer =#QueueArgsConfigurer因为我使用的是spring,所以我通过Bean名称获得了QueueArgsConfigurer.

And add to queue endpoint queueArgsConfigurer option like this: queueArgsConfigurer=#QueueArgsConfigurerSince I am using spring I get the QueueArgsConfigurer by its bean name.

这篇关于无法按优先顺序获取消息Spring骆驼rabbitmq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 05:37