[bot-cherry-pick]Support topic-level max message size #8748
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.
fix https://github.com/streamnative/pulsar/issues/1723
Motivation
The current policy to control the size of the message is at the broker level(maxMessageSize). It becomes easier to plan resource quotas for client allocation if the max message size pushed can be given at the topic level.
Modifications
Now the broker-level
maxMessageSizeis returned by the broker to the client, when the broker handleshandleConnected. The client will cachedmaxMessageSizelocally. An exception will be thrown if it exceeds the limit.Topic-level cannot be implemented like this, because:
handleConnected, the command received by the broker does not contain specific topic information, so it is not known which topic policy to return to the client.I think the best way to handle this is to let the broker determine whether it exceeds the limit, and return an exception if it exceeds the limit, and handle the exception by the client's
handleSendError.Verifying this change
TopicPoliciesTest.java
(cherry picked from commit 9c28378)