From 2dace760b03bd679dae5ea682e1e23fd93c15f78 Mon Sep 17 00:00:00 2001 From: Jiwei Guo Date: Fri, 11 Oct 2024 09:16:50 +0800 Subject: [PATCH] [improve][client] Add log when can't add message to the container (#21924) --- .../java/org/apache/pulsar/client/impl/MessagesImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessagesImpl.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessagesImpl.java index d4cd36a22e15f..9768fd7c74b0f 100644 --- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessagesImpl.java +++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessagesImpl.java @@ -22,11 +22,13 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import lombok.extern.slf4j.Slf4j; import net.jcip.annotations.NotThreadSafe; import org.apache.pulsar.client.api.Message; import org.apache.pulsar.client.api.Messages; @NotThreadSafe +@Slf4j public class MessagesImpl implements Messages { private final List> messageList; @@ -49,10 +51,14 @@ protected boolean canAdd(Message message) { return true; } if (maxNumberOfMessages > 0 && currentNumberOfMessages + 1 > maxNumberOfMessages) { + log.warn("can't add message to the container, has exceeded the maxNumberOfMessages : {} ", + maxNumberOfMessages); return false; } if (maxSizeOfMessages > 0 && currentSizeOfMessages + message.size() > maxSizeOfMessages) { + log.warn("can't add message to the container, has exceeded the maxSizeOfMessages : {} ", + maxSizeOfMessages); return false; }