Skip to content

Provide queue name and reason to publisher for rejected messages#15075

Merged
ansd merged 1 commit intomainfrom
reject
Dec 9, 2025
Merged

Provide queue name and reason to publisher for rejected messages#15075
ansd merged 1 commit intomainfrom
reject

Conversation

@ansd
Copy link
Copy Markdown
Member

@ansd ansd commented Dec 5, 2025

What?

  1. This commit adds the name of the queue that rejected a message as well as the reason why the message was rejected in the Rejected outcome for AMQP 1.0.
  2. For MQTT 5.0 publishers, the reason is provided in the PUBACK packet.

Why?

It may be helpful for publishers to know which queue out of multilple target queues rejected the message. One such use case is described in #1443 It may also be helpful to know for publishers whether the given target queue rejected the message because its maximum queue length was reached or because the target queue happens to be unavailable.

How?

RabbitMQ will include the UTF-8 encoded queue name (rather than an AMQP address) as well as the reason in the info field of the Rejected outcome's error field:

  • queue: <queue name>
  • reason: maxlen | unavailable

For MQTT 5.0, if the queue length limit is exceeded, RabbitMQ will return the reason code for Quota exceeded to the publisher.

Docs PR: rabbitmq/rabbitmq-website#2413

 ## What?
1. This commit adds the name of the queue that rejected a message as well
as the reason why the message was rejected in the Rejected outcome for AMQP 1.0.
2. For MQTT 5.0 publishers, the reason is provided in the PUBACK packet.

 ## Why?
It may be helpful for publishers to know which queue out of multilple
target queues rejected the message. One such use case is described in
#1443
It may also be helpful to know for publishers whether the given target
queue rejected the message because its maximum queue length was reached
or because the target queue happens to be unavailable.

 ## How?
RabbitMQ will include the UTF-8 encoded queue name (rather than an AMQP
address) as well as the reason in the `info` field of the Rejected outcome's `error` field:
* `queue: <queue name>`
* `reason: maxlen | unavailable`

For MQTT 5.0, if the queue length limit is exceeded, RabbitMQ will
return the reason code for `Quota exceeded` to the publisher.
@ansd ansd marked this pull request as ready for review December 8, 2025 06:56
@michaelklishin
Copy link
Copy Markdown
Collaborator

For STOMP, we can add these values via x-* headers on the NACK frame.

AMQP 0-9-1 would require a protocol extension similarly to how basic.nack emerged because basic.reject was lacking the necessary fields.

@ansd
Copy link
Copy Markdown
Member Author

ansd commented Dec 9, 2025

For STOMP, we can add these values via x-* headers on the NACK frame.

The NACK frame is the wrong frame because the NACK frame is sent from client to server. "NACK is the opposite of ACK. It is used to tell the server that the client did not consume the message."

Instead, the target queue and reason why RabbitMQ rejected a message would need to be included in the STOMP ERROR frame. That's something we can do in future as part of Native STOMP.

@ansd ansd merged commit da0eb09 into main Dec 9, 2025
291 checks passed
@ansd ansd deleted the reject branch December 9, 2025 08:41
ansd added a commit that referenced this pull request Dec 9, 2025
 ### What?
This commit is a follow-up to #15075
setting the `description` field of the AMQP `error` if RabbitMQ rejects
a message.

 ### Why?
Client libs can then just pass this error description string to client
apps, which in turn could optionally log that message.
ansd added a commit that referenced this pull request Dec 9, 2025
 ### What?
This commit is a follow-up to #15075
setting the `description` field of the AMQP `error` if RabbitMQ rejects
a message.

 ### Why?
Client libs can then just pass this error description string to client
apps, which in turn could optionally log that message.
ansd added a commit that referenced this pull request Dec 10, 2025
This is a follow up to #15075
For maximum queue length exceeded use more appropriate error condition
`resource-limit-exceeded` (instead of `precondition-failed`).
ansd added a commit that referenced this pull request Dec 10, 2025
This is a follow up to #15075
For maximum queue length exceeded use more appropriate error condition
`resource-limit-exceeded` (instead of `precondition-failed`).
michaelklishin pushed a commit that referenced this pull request Dec 11, 2025
 ### What?
This commit is a follow-up to #15075
setting the `description` field of the AMQP `error` if RabbitMQ rejects
a message.

 ### Why?
Client libs can then just pass this error description string to client
apps, which in turn could optionally log that message.
michaelklishin pushed a commit that referenced this pull request Dec 11, 2025
This is a follow up to #15075
For maximum queue length exceeded use more appropriate error condition
`resource-limit-exceeded` (instead of `precondition-failed`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants