- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我的基本问题是,在任何 1 小时的时间段内,我只能处理来 self 的一个队列(跨所有机器)的 7000 条消息。我看不到用 camel 或 activemq 来做到这一点的方法,所以我求助于实现我自己的路由停止/启动逻辑。我看到了很多方法可以做到这一点,我已经尝试了其中的一些(只是遇到了问题)。
camelContext.stopRoute(route)
:这在停止处理消息时有效,但是当我调用 camelContext.startRoute(route)
时,它泄漏了一个 tcp 连接最终导致 activemq 服务器达到其极限并死亡。camelContext.suspendRoute(route)
:这也会停止处理消息并且不会泄漏连接,但它似乎会杀死在以下情况下不会重新激活的活跃消费者(在管理面板中可见)我调用 camelContext.resumeRoute(route)
。我认为这最终可能导致该队列中根本没有消息被处理,即使我恢复也是如此。RoutePolicy
。公平地说,我还没有尝试过这个,但根据我在上面选择的暂停方法,它似乎会成为我遇到的同样问题的牺牲品。有没有解决这个问题的方法我还没有遇到过?
最佳答案
与其停止路线,我建议使用 Throttler EIP .
from("jms:queue:inbox")
.throttle(7000)
.timePeriodMillis(1000*60*60)
.to("log:result", "mock:result");
上面的例子会限制在 jms:queue:inbox
上收到的消息,然后再发送到 mock:result
确保在任何 1 小时内最多发送 7000 条消息窗口。
或者,为了更细粒度的控制,您可以定义限制路由策略,如 Camel 的 throttling example 所示。 :
<route routePolicyRef="myPolicy">
<from uri="jms:queue:inbox"/>
<transacted/>
<to uri="log:+++JMS +++?groupSize=100"/>
<to ref="foo"/>
</route>
节流警察定义如下:
<bean id="myPolicy" class="org.apache.camel.impl.ThrottlingInflightRoutePolicy">
<property name="scope" value="Context"/>
<!-- when we hit > 20 inflight exchanges then kick in and suspend the routes -->
<property name="maxInflightExchanges" value="20"/>
<!-- when we hit lower than 10% of the max = 2 then kick in and resume the routes the default percentage is 70% but in this demo we want a low value -->
<property name="resumePercentOfMax" value="10"/>
<!-- output throttling activity at WARN level -->
<property name="loggingLevel" value="WARN"/>
</bean>
编辑 1:
如果需要全局限流,那么可以先让一个消费者读取消息,按照上面的方法对所有消息进行限流,然后重新发送到另一个队列,让其重新读取和处理他们由 >= 1 分布式消费者。
编辑 2:
或者,您可以实现自己的ThrottlingInflightRoutePolicy
来访问保存处理信息的中央数据库。这样,您就不需要“单节点主节流器”。但是,数据库也可能是单点故障。
关于java - 使用 camel 和 activemq 到 "pause"路由的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26283548/
场景: private readonly IConnection connection; this.connection = connectionFactory.CreateConnection();
想知道是否可以在 activeMQ 服务器中完成任何配置,将消息从 DLQ 重定向到同一服务器上的另一个队列。 例如。 我有一个队列“MAINQUEUE”,其中有很多消息已激活客户端确认,在处理时如果
我正在 ActiveMQ 中的一个系统上工作,我真的不想丢失消息。我的问题是重试消息导致我的消费者阻塞(而不是处理他们可以处理的消息)。我想给失败的消息几天重试(例如,我的潜在目的地之一是我将通过 S
我们对 AMQ 使用以下配置 定期我有奇怪的问题 - 松散的消息。实际上AMQ说一切正常并且消
我已按照教程安装 ActiveMQ http://servicebus.blogspot.com/2011/02/installing-apache-active-mq-on-ubuntu.html
当我们使用 ActiveMQ 时,我们可以信任 ActiveMQ 服务器的可靠性。例如在开发非实时软件时(不需要立即发送数据。但应该发送)。我们能否信任 activeMQ 作为确认消息传递的可靠来源。
我遇到了 issue使用 ActiveMQ 并希望跟踪/查看所有 ActiveMQ 事件。我能找到的唯一日志文件是与持久数据相关联的(如果打开的话)。我是否查看或生成了任何其他日志文件来告诉我 Act
我们正面临 ActiveMQ 及其使用者的随机问题。我们观察到,即使连接到 ActiveMQ 队列,也很少有消费者没有收到消息。但是在消费者重启后它工作正常。 我们在 ActiveMQ 端有一个名为
有什么方法可以跟踪 ActiveMQ 中的延迟(计划)消息? 我在 AMQ 网络控制台中没有看到任何东西,它们似乎只有在延迟到期时才进入队列……而且我在 JMX 控制台中也找不到它,也许我搜索得不够好
我对Apache ActiveMQ的功能感到困惑。 我从this link下载了ActiveMQ 。所以我这样使用它(环境:Windows 7):我启动 bin/activemq.bat,然后它就可以
我们有一个 ActiveMQ 代理,它使用 JMS、AMQP 和 MQTT 连接到不同的客户端。由于某种原因,我们还没有弄清楚一组特定的 MQTT 客户端经常(并非总是)持久订阅。这是一个测试环境,其
在activemq中有什么方法可以获取消息的数量代理端每秒/每分钟消耗/产生的数量? 我已经尝试使用http://activemq.apache.org/jmeter-performance-test
如何在队列上的 ActiveMQ 中设置 redeliveryPolicy? 1) 在文档中,请参阅:activeMQ Redelivery ,说明您应该在 ConnectionFactory 或 C
我查了一下,它用于在两个系统之间发送消息。 但为什么?为什么不直接使用数据库? 一定有一些 ActiveMQ 具有 数据库 没有的功能吗? 最佳答案 它用于在两个分布式进程之间进行可靠的通信。 是的,
我在生产系统中运行 ActiveMQ。我们的一些队列的流量非常大,而有些队列的流量非常低。我对镜像其中一个低容量队列感兴趣,这样我就可以围绕接收到的消息构建非正式的监控服务。 不幸的是,the onl
我们已经使用此配置为 ActiveMQ Broker 配置了 Broker redelivery 插件。
有什么方法可以检查特定队列是否已存在于 ActiveMQ 中? 最佳答案 http://activemq.apache.org/how-can-i-get-a-list-of-the-topics-a
有人知道如何将 activemq-core.xsd url 与 jar 文件 (activemq-core-5.2.0.jar) 中的 activemq.xsd 关联起来? 我在互联网上找到了一些解决
我是 activemq 的新手。我试图使用 activemq 代理来订阅/发布消息。但至于缺乏经验,我不知道该怎么做,也不知道是否真的可以做到。我在谷歌上搜索了很多,但不幸的是,没有适合此类功能的示例
我一直在努力配置 ActiveMQ 代理,让我感到困惑的一件事是,我读过的所有内容都将 NIO 描述为“如果您需要扩展的不错选择”或“如果您需要更快的速度” ,所以我的问题是他们为什么不说“总是使用
我是一名优秀的程序员,十分优秀!