activemq如何从具有特殊顺序的队列中获取消息 [英] activemq how to get message from queue with special order

查看:73
本文介绍了activemq如何从具有特殊顺序的队列中获取消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个队列,消息的属性名称为orderno如何从按orderno排序的队列中获取消息

I have a queue that messages has properties name orderno how can I fetch message from queue sorted by orderno

推荐答案

您实际上想做的是重排序器企业集成模式

您可以使用与ActiveMQ捆绑在一起的Apache Camel来实现.

You can achieve that using Apache Camel, which is bundled with ActiveMQ.

您需要做的是将以下内容添加到ActiveMQ中的"camel.xml"配置文件中.

What you need to do is to add the following to the ´camel.xml´ config file in ActiveMQ.

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="activemq:queue:unordered"/>
    <resequence>
       <simple>in.header.orderno</simple>
       <to uri="activemq:queue:ordered" />
       <stream-config capacity="5000" timeout="4000"/>
    </resequence>
  </route>
</camelContext>

然后只需确保该文件包含在ActiveMQ配置中,例如activemq.xml:

Then just make sure that file is included inside your ActiveMQ config, such as activemq.xml:

<import resource="camel.xml"/>

请注意,此设置将以任何顺序从无序"队列中读取消息,而您的应用程序应从有序"队列中读取重新排序的消息.

Note that this setup will read messages in any order from the "unordered" queue, while your application should read the re-ordered from the "ordered" queue.

这篇关于activemq如何从具有特殊顺序的队列中获取消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆