Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][client]Add logging for message size exceeding the configured threshold before throwing exception #23681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2413,11 +2413,16 @@ private void recoverProcessOpSendMsgFrom(ClientCnx cnx, MessageImpl from, long e
private boolean isMessageSizeExceeded(OpSendMsg op) {
if (op.msg != null && !conf.isChunkingEnabled()) {
int messageSize = op.getMessageHeaderAndPayloadSize();
if (messageSize > getMaxMessageSize()) {
int maxMessageSize = getMaxMessageSize();
if (messageSize > maxMessageSize) {
// Log the message size exceeding the limit
log.warn("Message size exceeded: Producer {} attempted to send a message of {} bytes, "
+ "exceeding the configured maximum size of {} bytes on topic {}.",
producerName, messageSize, maxMessageSize, topic);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems useless for this log, the client could get the exception with log below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, the exception can be propagated to the send oeration.

releaseSemaphoreForSendOp(op);
op.sendComplete(new PulsarClientException.InvalidMessageException(
format("The producer %s of the topic %s sends a message with %d bytes that exceeds %d bytes",
producerName, topic, messageSize, getMaxMessageSize()),
producerName, topic, messageSize, maxMessageSize),
op.sequenceId));
return true;
}
Expand Down
Loading