0
votes

Using below configuration aplication.yml, for a consumer application through Spring Cloud Stream 3.0.12.RELEASE and 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

I am trying to manage error handling with republishToDlq to route the messages which throw exception together with exception stack trace. In the document it is told that;

2. RabbitMQ Binder Overview

..." In addition, republishToDlq causes the binder to publish a failed message to the DLQ (instead of rejecting it). This feature lets additional information (such as the stack trace in the x-exception-stacktrace header) be added to the message in headers."

When I check the queue some-topic-vhost2.some-events.dlq, I figure out that the message which throws exception routed to that queue. It is OK. But the exception stack trace is not added as a header. And also, the applicaiton send as a warning below,

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

What is wrong with this config. What should I do to enable republishToDlq

1

1 Answers

0
votes

You probably missing some configuration. Here is a working example I provided for a different question - https://github.com/olegz/stream-function-samples/tree/main/stream-rabbit-dlq Although it this example is specific to RoutingFunction, it is just like any other function, so you can easily retrofit it to your case by changing all properties that use functionRouter-in-0 to your consumeSomething-in-0.