gpt4 book ai didi

java - 如何消费Spring Cloud Stream中默认死信队列的消息?

转载 作者:行者123 更新时间:2023-11-30 05:28:30 28 4
gpt4 key购买 nike

我配置了默认的 DLQ,如下所示:

spring:
cloud:
stream:
rabbit:
default:
consumer:
auto-bind-dlq: true
republish-to-dlq: true
dead-letter-queue-name: my-dlq

我想使用默认 DLQ 中的消息并在业务域中处理它。

如何使用Spring Cloud Stream收听这些消息?

谢谢

最佳答案

没有内置任何内容,但是 the documentation shows some techniques ...

Because you cannot anticipate how users would want to dispose of dead-lettered messages, the framework does not provide any standard mechanism to handle them. If the reason for the dead-lettering is transient, you may wish to route the messages back to the original queue. However, if the problem is a permanent issue, that could cause an infinite loop. The following Spring Boot application shows an example of how to route those messages back to the original queue but moves them to a third “parking lot” queue after three attempts. The second example uses the RabbitMQ Delayed Message Exchange to introduce a delay to the re-queued message. In this example, the delay increases for each attempt. These examples use a @RabbitListener to receive messages from the DLQ. You could also use RabbitTemplate.receive() in a batch process.

...

关于java - 如何消费Spring Cloud Stream中默认死信队列的消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58034395/

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