繁体   English   中英

Spring Cloud Stream RabbitMQ Binder Consumer Properties republishToDlq 对我不起作用

[英]Spring Cloud Stream RabbitMQ Binder Consumer Properties republishToDlq not working for me

使用以下配置 aplication.yml,用于通过 Spring Cloud Stream 3.0.12.RELEASE 和 Spring Boot 2.5.6 的消费者应用程序

spring:
  main:
    web-application-type: none
  cloud:
    stream:      
      bindings:
        consumeSomething-in-0:
          destination: some-topic-vhost2
          group: some-events
          binder: local_rabbit
          consumer:
            max-attempts: 1
            auto-bind-dlq: true
            dlq-ttl: 50000
            republishToDlq: true

我正在尝试使用republishToDlq管理错误处理,以路由抛出异常和异常堆栈跟踪的消息。 在文件中它被告知;

2. RabbitMQ Binder 概述

...”此外,republishToDlq 会导致绑定器将失败的消息发布到 DLQ(而不是拒绝它)。此功能允许将附加信息(例如 x-exception-stacktrace 标头中的堆栈跟踪)添加到标题中的消息。”

当我检查队列some-topic-vhost2.some-events.dlq ,我发现抛出异常的消息路由到该队列。 没关系。 但是异常堆栈跟踪没有作为标题添加。 而且,应用程序在下面作为警告发送,

o.s.c.s.b.r.RabbitMessageChannelBinder   : 'republishToDlq' is true, but the 'DLX' dead letter exchange is not present; disabling 'republishToDlq'

这个配置有什么问题。 我应该怎么做才能启用republishToDlq

您可能缺少一些配置。 这是我为不同问题提供的一个工作示例 - https://github.com/olegz/stream-function-samples/tree/main/stream-rabbit-dlq虽然这个示例特定于 RoutingFunction,但它就像任何其他功能,因此您可以通过将使用functionRouter-in-0所有属性更改为您的consumeSomething-in-0来轻松地将其改装到您的案例consumeSomething-in-0

除了上面提到的 Oleg 之外,我认为您设置兔子绑定属性的配置存在一些小问题。 必须在rabbit绑定本身上设置一些 Rabbit 消费者特定的属性。 请参阅下文并注意配置中的rabbit间接性。 max-attempts和其他绑定属性可以保留在您的配置中。

spring:
  cloud:
    stream: 
      bindings:
          consumeSomething-in-0:
            destination: some-topic-vhost2
            group: some-events
            binder: local_rabbit
            consumer:
              max-attempts: 1 
      rabbit    
        bindings:
          consumeSomething-in-0:
            consumer:
              auto-bind-dlq: true
              dlq-ttl: 50000
              republishToDlq: true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM