Search code examples
springspring-cloud-streamspring-rabbit

Spring Cloud Stream remove x-exception-stacktrace from DLQ Message


we try to remove the "x-exception-stacktrace" from the DLQ messages to make the footprint of republish messages smaller.

We use the default spring mechanism with

spring:
  cloud:
    stream:
      default:
        consumer:
          maxAttempts: 1 
      bindings:
        foo:
          destination: bar
      rabbit:
        default:
          binder: service_rabbit
          consumer:
            contentType: application/json
            republishToDlq: true
            autoBindDlq: true
            dlqTtl: 1000
            dlq-dead-letter-exchange:

If a message is repeated multiple times, the "x exception stacktrace" is always copied and the message becomes even longer. We also log everything so the header is useless to use. Is there a way to remove the header?

We try to increase the frameMaxHeadroom but it has no effect.


Solution

  • The frameMaxHeadRoom property should work. I just tested it and it worked for me...

    enter image description here

    However, there is a bug; if frameMaxHeadroom is too large, it is ignored, it must be less than RabbitUtils.getMaxFrame(connectionFactory) to work; we should assume 0 available for the trace if it is larger.

    In my case, that value is 131072; with the example above (that worked), I used frame-max-head-room: 131000; leaving just 72 bytes for the trace.

    It should be possible to add a MessagePostProcessor to the binder's template for DLQs, in RabbitTemplate.setBeforePublishPostProcessors(), to manipulate the headers, but that is not currently possible.

    Please open a new feature issue on GitHub (spring-cloud-stream).