gpt4 book ai didi

java - 如何在发送到 DLQ 之前处理消息

转载 作者:行者123 更新时间:2023-12-02 03:02:30 24 4
gpt4 key购买 nike

我正在使用以下服务器端重新传递配置

 <plugins>
<redeliveryPlugin fallbackToDeadLetter="true" sendToDlqIfMaxRetriesExceeded="true">
<redeliveryPolicyMap>
<redeliveryPolicyMap>
<redeliveryPolicyEntries>
<redeliveryPolicy
queue = "com.api.RequestQueue.v1"
maximumRedeliveries="20"
initialRedeliveryDelay="60000"
redeliveryDelay="60000" />

<redeliveryPolicy
queue = "com.api.RequestQueue.v2"
maximumRedeliveries="10"
initialRedeliveryDelay="30000"
redeliveryDelay="30000" />
<redeliveryPolicy
queue = "com.api.ResponseQueue.v1"
maximumRedeliveries="3"
initialRedeliveryDelay="34000"
redeliveryDelay="34000" />
</redeliveryPolicyEntries>
</redeliveryPolicyMap>
</redeliveryPolicyMap>
</redeliveryPlugin>
</plugins>

如何设置自定义端点来在重试后和发送到 DLQ 之前处理失败的消息?我确实引用了以下链接,但找不到任何有关服务器端或 redeliveryPlugin 配置的内容

1. dead-letter-channel

2. logging-camel-exceptions-and-sending-to-the-dead-letter-channel

最佳答案

如果您使用蓝图或 spring,那么可以轻松完成,如下所示:

<!-- Redelivery Policy -->
<bean class="org.apache.camel.processor.RedeliveryPolicy" id="redeliveryPolicyConfig">
<property name="5" />
<property name="redeliveryDelay" value="5000" />
<property name="logRetryAttempted" value="true" />
</bean>

<!-- Error Handler -->
<bean class="org.apache.camel.builder.DeadLetterChannelBuilder" id="errorHandler">
<property name="deadLetterUri" value="direct:error" />
<property name="useOriginalMessage" value="true" />
<property name="redeliveryPolicy" ref="redeliveryPolicyConfig" />
</bean>

然后在“deadLetterUri”属性中添加错误处理程序指向的路由,如下所示:

<!-- Perform custom logic and send to DLQ -->
<route id="myDLQ-route">
<from uri="direct:error" />
<!-- Maybe some logic here, logging perhaps? -->
<to uri="activemq:queue:myDLQ" />
</route>

关于java - 如何在发送到 DLQ 之前处理消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42250527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com