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][consumer] Optimizing Exception Handling and Logging in MultiTopicsConsumerImpl #23568

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 @@ -372,7 +372,7 @@ public int minReceiverQueueSize() {

@Override
protected Message<T> internalReceive() throws PulsarClientException {
Message<T> message;
Message<T> message = null;
try {
if (incomingMessages.isEmpty()) {
expectMoreIncomingMessages();
Expand All @@ -383,6 +383,12 @@ protected Message<T> internalReceive() throws PulsarClientException {
unAckedMessageTracker.add(message.getMessageId(), message.getRedeliveryCount());
resumeReceivingFromPausedConsumersIfNeeded();
return beforeConsume(message);
} catch (IllegalArgumentException e) {
Copy link
Member

Choose a reason for hiding this comment

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

It looks checkState(message instanceof TopicMessageImpl); will throw this exception.

When will this happen? Could you shared your case?

log.error("Validation failed: Expected instance of TopicMessageImpl but received {}. Message ID: {}",
message != null ? message.getClass().getName() : "null",
message != null ? message.getMessageId() : "N/A",
e);
throw new PulsarClientException("Invalid message type received", e);
} catch (Exception e) {
ExceptionHandler.handleInterruptedException(e);
throw PulsarClientException.unwrap(e);
Expand All @@ -391,7 +397,7 @@ protected Message<T> internalReceive() throws PulsarClientException {

@Override
protected Message<T> internalReceive(long timeout, TimeUnit unit) throws PulsarClientException {
Message<T> message;
Message<T> message = null;
try {
if (incomingMessages.isEmpty()) {
expectMoreIncomingMessages();
Expand All @@ -405,6 +411,12 @@ protected Message<T> internalReceive(long timeout, TimeUnit unit) throws PulsarC
}
resumeReceivingFromPausedConsumersIfNeeded();
return message;
} catch (IllegalArgumentException e) {
log.error("Validation failed: Expected instance of TopicMessageImpl but received {}. Message ID: {}",
message != null ? message.getClass().getName() : "null",
message != null ? message.getMessageId() : "N/A",
e);
throw new PulsarClientException("Invalid message type received", e);
} catch (Exception e) {
ExceptionHandler.handleInterruptedException(e);
throw PulsarClientException.unwrap(e);
Expand Down
Loading