繁体   English   中英

ActiveMQ:如何根据指定的时间段使用队列中的消息

[英]ActiveMQ:How to consume the Messages on a queue based on a specified time period

我有一个队列,我需要根据特定时间段使用消息。让我说,每五分钟我需要开始使用消息并进行处理。 目前,我正在使用计时器来触发路由并处理消息,但是以下代码不起作用。

下面的代码来自我的蓝图

路线:

计时器值=“ timer:// errorMessageProcessorTimer?period = 120000”

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>

这是不可能有两个from标签在一个路线!

看一看企业集成模式 有一种叫做Throttler的东西。 也许这对您有帮助。

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>

查看控制总线EIP模式,如何将消息发送到“控制总线”端点并使其启动/停止。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM