C++ ActiveMQ和cpp中的重试逻辑

C++ ActiveMQ和cpp中的重试逻辑,c++,activemq,activemq-cpp,C++,Activemq,Activemq Cpp,我很难在ActiveMQ中获得有限的重试次数和死信队列。我正在linux中使用activemq cpp库进行开发 这就是我想做的: 在代理上设置DLQ和重试策略(下面是xml,已启用schedulerSupport) 使用自动确认针对队列注册cms::MessageListener 根据以下政策,在SEGFULT期间重新发送消息 我真的不想: 使用事务性消息传递(提交/回滚..可以接受其他ack模式) 在客户端处理重试逻辑(由于存在SEGFULT可能性) 我观察到: 当cpp exe因

我很难在ActiveMQ中获得有限的重试次数和死信队列。我正在linux中使用activemq cpp库进行开发

这就是我想做的:

  • 在代理上设置DLQ和重试策略(下面是xml,已启用schedulerSupport)
  • 使用自动确认针对队列注册cms::MessageListener
  • 根据以下政策,在SEGFULT期间重新发送消息
我真的不想:

  • 使用事务性消息传递(提交/回滚..可以接受其他ack模式)
  • 在客户端处理重试逻辑(由于存在SEGFULT可能性)
我观察到:

  • 当cpp exe因SEGFULT崩溃时,消息将毫不延迟地返回队列,并且无论有多少次重新传递,消息都不会路由到DLQ。这意味着服务器将进入一个无限的崩溃循环,其中包含有毒消息
  • 如果handleMessage调用完成,消息将按预期消失
到目前为止,我发现的一切都是java示例,似乎暗示我在这里想做的事情是不可能的。“Don crash”对我来说不是一个有效的答案,因为这是一个大型应用程序,需要进行大量的交叉开发,所以在测试环境中保证零故障是不可能的

谢谢

  <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>