Skip to content

Commit

Permalink
[improve][client] Add log when can't add message to the container (ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
Technoboy- authored Oct 11, 2024
1 parent bc3e7f6 commit 2dace76
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> implements Messages<T> {

private final List<Message<T>> messageList;
Expand All @@ -49,10 +51,14 @@ protected boolean canAdd(Message<T> 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;
}

Expand Down

0 comments on commit 2dace76

Please sign in to comment.