[英]ActiveMQ:How to consume the Messages on a queue based on a specified time period
I have a queue and i need to consume the messages based on a specific time period.Let say, for every five minutes i need to start consuming the messages and process them. 我有一个队列,我需要根据特定时间段使用消息。让我说,每五分钟我需要开始使用消息并进行处理。 Currently i am using a timer to trigger the route and process the messages but the below code is not working.
目前,我正在使用计时器来触发路由并处理消息,但是以下代码不起作用。
The below code is from my blueprint 下面的代码来自我的蓝图
Route: 路线:
timer value="timer://errorMessageProcessorTimer?period=120000" 计时器值=“ timer:// errorMessageProcessorTimer?period = 120000”
errorqueue.in value="activemq:Q.ERROR" errorqueue.in value =“ activemq:Q.ERROR”
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="errorNotificationFilterRoute">
<from uri="{{timer}}"/>
<to uri="direct:processErrorMessage"/>
</route>
<route id="processErrorMessage">
<from uri="direct:processErrorMessage"/>
<from uri="{{errorqueue.in}}" />
<log loggingLevel="INFO" logName="errormessage" message="Error Notification Queue reading the error message..." />
<filter>
<simple>${body} contains 'xxxxx'</simple>
<to uri="file:C:\\datafiles\\output"/>
<log loggingLevel="INFO" logName="errormessage" message="Error message processed succesfully...." />
</filter>
</route>
</camelContext>
It is not possible to have two from
Tags in one Route! 这是不可能有两个
from
标签在一个路线!
Take a look to the Enterprise Integration Patterns . 看一看企业集成模式 。 There is something called Throttler.
有一种叫做Throttler的东西。 Maybe this helps you.
也许这对您有帮助。
The Throttler Pattern allows you to ensure that a specific endpoint does not get overloaded, or that we don't exceed an agreed SLA with some external service.
Throttler模式可让您确保特定的端点不会过载,或者我们不会超出某些外部服务的商定SLA。
<route id="processErrorMessage">
<from uri="{{errorqueue.in}}" />
<!-- throttle 3 messages per 10 sec -->
<throttle maximumRequestsPerPeriod="3" timePeriodMillis="10000">
<log loggingLevel="INFO" logName="errormessage" message="Error Notification Queue reading the error message..." />
</route>
See the control bus EIP pattern how you can send a message to a 'controlbus' endpoint and have it start/stop rotues. 查看控制总线EIP模式,如何将消息发送到“控制总线”端点并使其启动/停止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.