使用camel通过activemq启用优先级
在尝试使用 activemq 激活优先级后,我被告知尝试使用骆驼(请参阅此处)。但我无法让它工作,我什至不知道它应该如何工作。
我在我的 spring 配置中添加了以下代码:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="jms:queue:myqueue" />
<resequence>
<batch-config batchSize="200" batchTimeout="3000" allowDuplicates="true" reverse="true"/>
<header>JMSPriority</header>
<to uri="mock:result"/>
</resequence>
</route>
</camelContext>
<bean id="jmsConfig" class="org.apache.camel.component.activemq.ActiveMQConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="concurrentConsumers" value="10"/>
</bean>
<bean id="activemq" class="org.apache.camel.component.activemq.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>
但是此配置不起作用(没有订购任何内容),并且我有几个问题:
mock:result
是什么意思?我在文档中找不到它。- 骆驼应该如何重新排序队列,是在创建消息之后完成,还是在添加消息时完成?
- 可以独立于spring activemq基本配置吗? (我这里使用camel ActiveMQComponent)
After trying to activate priority with activemq, I was told to try using camel (see here). But I can't get it working, and I'm not even sure how it should work.
I've added the following code, in my spring configuration:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="jms:queue:myqueue" />
<resequence>
<batch-config batchSize="200" batchTimeout="3000" allowDuplicates="true" reverse="true"/>
<header>JMSPriority</header>
<to uri="mock:result"/>
</resequence>
</route>
</camelContext>
<bean id="jmsConfig" class="org.apache.camel.component.activemq.ActiveMQConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="concurrentConsumers" value="10"/>
</bean>
<bean id="activemq" class="org.apache.camel.component.activemq.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>
But this configuration doesn't work (nothing is ordered), and I have a few questions:
- What does
mock:result
mean? I couldn't find it in the documentation. - How is camel supposed to re-order the queue, is it done after the messages were created, or when a message is added?
- Can it be independent from the spring activemq basic configuration? (I use here the camel ActiveMQComponent)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先, mock 端点用于单元测试。您可以使用它来验证是否收到了预期的消息:
接下来,重新排序器旨在排序基于某些属性的消息(在您的情况下为标头“JMSPriority”),并将在给定的超时期限或批量大小(默认情况下,批量大小为 100,超时为 1000)内对流经它的所有消息执行此操作 多发性硬化症)。
长话短说,您可以使用 resequencer 在消息发送到之前对消息进行排序(批量)队列、队列之间或队列和消费者之间......
First, a mock endpoint is for unit testing. You can use it to validate that the expected messages were received:
Next, the resequencer is designed to order messages based on some attribute (the header "JMSPriority" in your case) and will perform this over all messages that flow through it over a given timeout period or batch size (by default, the batch size is 100 and the timeout is 1000 ms).
Long story short, you can use the resequencer to order messages (in batches) before they are sent to the queue, in between queues or in between a queue and a consumer...