Apache的骆驼/ ActiveMQ的优先级路由 [英] Apache Camel/ActiveMQ priority route
问题描述
我有具有相同的消费者2 AMQ队列。
第一队列(Q 1)处理的消息的97%,而另一个(Q2)只有3%。
问题是,在Q2的消息需要,尽快为他们进行排队处理消息。
所以我的问题是,当一个消息在第二季度上市,我需要以某种方式暂停第一条路线把它的消费者。
Apache的骆驼路由看起来是这样的:
I have two AMQ queues that have the same consumers. The first queue (Q1) handles 97% of the messages and the other (Q2) only 3%. Problem is that messages in Q2 need to process messages as soon as they are queued. So my problem is that when a message is available in Q2 I need somehow to suspend the first route to take it's consumers. The apache camel routing looks like this:
<route id="q1">
<from uri="jms:recordAnalysisRequests" />
<to uri="bean:analysisService" />
</route>
<route id="q2">
<from uri="jms:recordAnalysisRequestsFastTrack" />
<to uri="bean:analysisService" />
</route>
应该使用什么策略?
我不认为我可以使用顺器,因为Q1可能有数以千计的邮件排队了,我不能适合所有的顺器一批。
我一直在寻找途径节流,但我无法弄清楚如何做到这一点。
我也想知道如果我可以通过一个动物园管理员节点同步。再次,我需要一些指导这里如果这个解决方案是可行的。
What strategy should use? I don't think I can use resequencer because Q1 could have thousands of messages queued up and I cannot fit all in a resequencer batch. I was looking at the route throttling but I cannot figure out how to do it. Also I was wondering if I can synchronize through a zookeeper node. Again I will need some guidance here if this solution is viable.
推荐答案
您可以将所有的信息在一个队列和使用消息优先级的 http://activemq.apache.org/how-can-i-support-priority-queues.html
You could place all messages in a single queue and use message priority http://activemq.apache.org/how-can-i-support-priority-queues.html
第二个选择,使用骆驼顺器
Second option, use a Camel Resequencer
<route id="q1">
<from uri="jms:recordAnalysisRequests" />
<setHeader headerName="CustomPriority">
<constant>2</constant>
</setHeader>
<to uri="direct:analysisDirect" />
</route>
<route id="q2">
<from uri="jms:recordAnalysisRequestsFastTrack" />
<setHeader headerName="CustomPriority">
<constant>1</constant>
</setHeader>
<to uri="direct:analysisDirect" />
</route>
<route id="q3">
<from uri="direct:analysisDirect">
<resequence>
<header>CustomPriority</header>
<to uri="bean:analysisService" />
</resequence>
</route>
第三个选项(骆驼2.12),采用顺器的insteads,使用SEDA端点创建一个PriorityBlockingQueue的 https://camel.apache.org/seda.html#SEDA-ChoosingBlockingQueueimplementation
这篇关于Apache的骆驼/ ActiveMQ的优先级路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!