Search code examples
javaspringrabbitmqspring-cloudspring-rabbit

RabbitMQ throws an exception when sending to dead letter queue (DLQ) (maximum frame_size)


When I got a message from the queue and if an exception was thrown, I wanted to get the message again.

So, I create my consumer with a DLQ queue:

spring:
  cloud:
    stream:
      bindings:
        to-send-output:
          destination: to-send-event
          producer:
            required-groups:
              - to-send-event-group
        to-send-input:
          destination: to-send-event
          group: to-send-event-group
          consumer:
            max-attempts: 1
            requeueRejected: true
      rabbit:
        bindings:
          # Forever retry
          to-send-input:
            consumer:
              autoBindDlq: true
              dlqTtl: 5000
              dlqDeadLetterExchange:
              maxConcurrency: 300
              frameMaxHeadroom: 25000 # I added this as in the documentation

I added the property frameMaxHeadroom: 25000 as it says in the documentation, but it still does not work.

My springCloudVersion="Hoxton.RELEASE".

My dependency:

dependencies {
...
    implementation "org.springframework.cloud:spring-cloud-starter-stream-rabbit"
...
}

In the repository on GitHub, I see the frameMaxHeadroom property in the property file.

I see that the code reduces the stack trace by the value I set (from a variable frameMaxHeadroom). I expected that I wasn't decreasing the stack trace, but increasing the value for the headers for the consumer, as written in the documentation. Why isn't it working as I wait?


Solution

  • frameMax is negotiated between the AMQP client and server; all headers must fit in one frame. You can increase it with the broker configuration.

    Stack traces can be large and can easily exceed the frameMax alone; in order to leave room for other headers, the framework leaves at least 20,000 bytes (by default) free for other headers, by truncating the stack trace header if necessary.

    If you are exceeding your frameMax, you must have other large headers. You need to increase the headroom to allow for those headers, so the stack trace is truncated further.