Open mawenyu opened 3 months ago
The problem of message duplication is difficult to avoid. The better solution now is to implement idempotence on the client side.
I solved this issue by modifying the consumer source code. Could you please ask the community if they would consider adopting this approach or if there are any more elegant solutions? The main modifications are:
org.apache.pulsar.client.impl.ConsumerImpl#connectionOpened
, call the parent consumer’s org.apache.pulsar.client.impl.MultiTopicsConsumerImpl
clearIncomingMessages(). —— This is necessary because Pulsar does not perform this cleanup , these message will cause duplicationorg.apache.pulsar.client.impl.ConsumerImpl#connectionOpened
delay the invoke of org.apache.pulsar.client.impl.ConsumerImpl#increaseAvailablePermits
by 3 seconds and execute it asynchronously. —— This 3-second delay allows the client to acknowledge the received messages.I solved this issue by modifying the consumer source code. Could you please ask the community if they would consider adopting this approach or if there are any more elegant solutions? The main modifications are:
- In the
org.apache.pulsar.client.impl.ConsumerImpl#connectionOpened
, call the parent consumer’sorg.apache.pulsar.client.impl.MultiTopicsConsumerImpl
clearIncomingMessages(). —— This is necessary because Pulsar does not perform this cleanup , these message will cause duplication
@mawenyu Interesting. This seems to be related to #21767 which is a draft PR I have.
- In the
org.apache.pulsar.client.impl.ConsumerImpl#connectionOpened
delay the invoke oforg.apache.pulsar.client.impl.ConsumerImpl#increaseAvailablePermits
by 3 seconds and execute it asynchronously. —— This 3-second delay allows the client to acknowledge the received messages.
Just wondering if the https://github.com/apache/pulsar/wiki/PIP-84-:-Pulsar-client:-Redeliver-command-add-epoch design or implementation has some gap.
@mawenyu Which Pulsar client version and Pulsar broker version are you using?
@mawenyu Which Pulsar client version and Pulsar broker version are you using?
3.0.4
Search before asking
Read release policy
Version
3.0.4
Minimal reproduce step
What did you expect to see?
bundle unload will not cause message duplication
What did you see instead?
bundle unload will not cause unacked message deliver to other consumer, which will cause data duplication
Anything else?
I think when consumer reconnected, consumer should first tell broker what messages they already hold , broker should redeliver these messages;
Are you willing to submit a PR?