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

Fix ack/nack use closed consumer #852

Open
wants to merge 18 commits 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
16 changes: 11 additions & 5 deletions pulsar/consumer_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ func (c *consumer) AckID(msgID MessageID) error {
}

if mid.consumer != nil {
return mid.Ack()
if pc, ok := (mid.consumer).(*partitionConsumer); ok && pc.getConsumerState() == consumerReady {
return mid.Ack()
Copy link
Member

@wolfstudy wolfstudy Oct 10, 2022

Choose a reason for hiding this comment

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

Thanks @billowqiu work for this, can we abstract a sharing method to check if the consumer object is active?

}
}

return c.consumers[mid.partitionIdx].AckID(mid)
Expand Down Expand Up @@ -522,8 +524,10 @@ func (c *consumer) Nack(msg Message) {
}

if mid.consumer != nil {
mid.Nack()
return
if pc, ok := (mid.consumer).(*partitionConsumer); ok && pc.getConsumerState() == consumerReady {
mid.Nack()
return
}
}
c.consumers[mid.partitionIdx].NackMsg(msg)
return
Expand All @@ -539,8 +543,10 @@ func (c *consumer) NackID(msgID MessageID) {
}

if mid.consumer != nil {
mid.Nack()
return
if pc, ok := (mid.consumer).(*partitionConsumer); ok && pc.getConsumerState() == consumerReady {
mid.Nack()
return
}
}

c.consumers[mid.partitionIdx].NackID(mid)
Expand Down