Improve the broker's handling of message corruption#2136
Merged
Conversation
This commit improves the brokers handling of messages that are corrupt and can't be read, such as unmarshaling the properties or body. Currently if there is an error an IOException is triggered and can lead to a client connection be closed. Furthermore for queues messages can be stuck and no new messages can be delivered. To improve things the following changes have been made: * The MarshallingSupport utility that is used to unmarshal message properties and bodies has improve validation to check for errors such is incorrectly encoded size values. * The broker will now handle message format errors both when messages are evaluated to add to subscriptions and during dispatch to consumers when the messages are already on a subscription. * The Stomp protocol converter was fixed to not auto ack or track acks until the message has been converted. * AMQP no longer swallows message format errors and will throw so the erors can be handled by the TransportConnection. All of these changes allow the broker to deal with corrupt messages and remove them (and possibly DLQ) vs causing the connections to close or the messages to block consumers forever in the queue case.
mattrpav
reviewed
Jun 22, 2026
mattrpav
reviewed
Jun 22, 2026
mattrpav
requested changes
Jun 22, 2026
mattrpav
requested changes
Jun 22, 2026
mattrpav
previously requested changes
Jun 22, 2026
tabish121
approved these changes
Jun 22, 2026
tabish121
left a comment
Contributor
There was a problem hiding this comment.
I can't spot any obvious issues, after all the fixes that have already been applied it seems reasonable to me.
Contributor
Author
|
All tests passed, I am going to merge and wrap up my second follow on PR |
changes were made to address concerns
cshannon
added a commit
that referenced
this pull request
Jun 23, 2026
This commit improves the brokers handling of messages that are corrupt and can't be read, such as unmarshaling the properties or body. Currently if there is an error an IOException is triggered and can lead to a client connection be closed. Furthermore for queues messages can be stuck and no new messages can be delivered. To improve things the following changes have been made: * The MarshallingSupport utility that is used to unmarshal message properties and bodies has improve validation to check for errors such is incorrectly encoded size values. * The broker will now handle message format errors both when messages are evaluated to add to subscriptions and during dispatch to consumers when the messages are already on a subscription. * The Stomp protocol converter was fixed to not auto ack or track acks until the message has been converted. * AMQP no longer swallows message format errors and will throw so the erors can be handled by the TransportConnection. All of these changes allow the broker to deal with corrupt messages and remove them (and possibly DLQ) vs causing the connections to close or the messages to block consumers forever in the queue case. (cherry picked from commit b20e61c)
cshannon
added a commit
that referenced
this pull request
Jun 23, 2026
This commit improves the brokers handling of messages that are corrupt and can't be read, such as unmarshaling the properties or body. Currently if there is an error an IOException is triggered and can lead to a client connection be closed. Furthermore for queues messages can be stuck and no new messages can be delivered. To improve things the following changes have been made: * The MarshallingSupport utility that is used to unmarshal message properties and bodies has improve validation to check for errors such is incorrectly encoded size values. * The broker will now handle message format errors both when messages are evaluated to add to subscriptions and during dispatch to consumers when the messages are already on a subscription. * The Stomp protocol converter was fixed to not auto ack or track acks until the message has been converted. * AMQP no longer swallows message format errors and will throw so the erors can be handled by the TransportConnection. All of these changes allow the broker to deal with corrupt messages and remove them (and possibly DLQ) vs causing the connections to close or the messages to block consumers forever in the queue case. (cherry picked from commit b20e61c)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves the broker' handling of messages that are corrupt and can't be read, such as when unmarshaling the properties or body. Currently if there is an error an IOException is triggered and can lead to a client connection be closed. Furthermore for queues messages can be stuck and no new messages can be delivered.
To improve things the following changes have been made:
The MarshallingSupport utility that is used to unmarshal message properties and bodies has improve validation to check for errors such is incorrectly encoded size values or a large stack depth of nested objects (limited to 127). This prevents problems such as large buffers being allocated by mistake.
The broker will now handle message format errors and there are two main spots errors had to be handled:
The Stomp protocol converter was fixed to not auto ack or track acks until the message has been converted.
AMQP no longer swallows message format errors and will throw so the errors can be handled by the TransportConnection.
Any compressed streams that are passed to MarshallingSupport now are wrapped using the new FrameSizeLimitedFilterInputStream class from Provide a flexible filter style input stream that limits read amounts #2118 so the utility doesn't break during inflation. As noted below a future PR will handle limiting the inflation amount.
All of these changes allow the broker to deal with corrupt messages and remove them (and possibly DLQ) vs causing the connections to close or the messages to block consumers forever in the queue case.
Note: There will be a follow on PR after this is merged to handle compressed message validation as well that builds on this.