Skip to content
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
Copy Markdown
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