如何解决重试ActiveMQ和cpp中的逻辑
要在ActiveMQ中进行有限的重试和死信队列,我遇到了很多困难。我正在使用Linux中的activemq-cpp库进行开发。
这就是我想要做的:
- 在代理上设置DLQ和重试策略(下面的xml,启用了schedulerSupport)
- 使用自动确认针对队列注册cms :: MessageListener
- 是否已根据以下政策在段错误期间重新传递了邮件。
我真的希望不必:
- 使用事务性消息传递(提交/回滚..其他ack模式可能是可以接受的)
- 在客户端处理重试逻辑(由于存在段错误的可能性)
我正在观察:
- 当cpp exe由于segfault而崩溃时,无论有多少次重新发送邮件,邮件都将立即返回队列,并且不会路由到DLQ。这意味着服务器进入中毒消息的无限崩溃循环。
- 如果handleMessage调用完成,则消息按预期消失。
到目前为止,我发现的所有内容都是java示例,似乎暗示我在这里想做的事情是不可能的。 “不要崩溃”对我来说不是一个有效的答案,因为这是一个大型应用程序,正在进行大量交叉开发,因此无法在测试环境中保证零段错误。
谢谢
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">">
<subscriptionRecoveryPolicy>
<fixedCountSubscriptionRecoveryPolicy maximumSize="100" />
</subscriptionRecoveryPolicy>
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information,see:
http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000" />
</pendingMessageLimitStrategy>
</policyEntry>
<policyEntry queue=">_REQ">
<deadLetterStrategy>
<!--
Use the prefix 'DLQ.' for the destination name,and make
the DLQ a queue rather than a topic. expire after 7 days
(604,800,000 ms)
-->
<individualDeadLetterStrategy queuePrefix="DLQ." useQueueForQueueMessages="true" expiration="604800000" processNonPersistent="true" />
</deadLetterStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
<plugins>
<redeliveryPlugin fallbackToDeadLetter="true"
sendToDlqIfMaxRetriesExceeded="true">
<redeliveryPolicyMap>
<redeliveryPolicyMap>
<!--
<redeliveryPolicyEntries>
<!-x- a destination specific policy -x->
<redeliveryPolicy queue="SpecialQueue"
maximumRedeliveries="4"
redeliveryDelay="10000"/>
</redeliveryPolicyEntries>
-->
<defaultEntry>
<!-- the fallback policy for all other destinations -->
<redeliveryPolicy maximumRedeliveries="4"
initialRedeliveryDelay="1000"
redeliveryDelay="5000"/>
</defaultEntry>
</redeliveryPolicyMap>
</redeliveryPolicyMap>
</redeliveryPlugin>
</plugins>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。