ruby-amqp / hutch

A system for processing messages from RabbitMQ.
https://gocardless.com/blog/hutch-inter-service-communication-with-rabbitmq/
MIT License
855 stars 137 forks source link

fix: reject and requeue double acknowledgement #388

Closed ahmedsaalah closed 1 year ago

ahmedsaalah commented 1 year ago

Fix Issue in (requeue! and reject! ) For Example: When you are using reject!

  1. Will broker.reject(delivery_info.delivery_tag) -> will go to def reject in broker.rb

  2. Will call channel.reject(delivery_tag, false)-> will go to bunny reject in channel.rb

  3. Will call basic_reject(delivery_tag.to_i, false) which going to reject the message So it's acknowledged

  4. In worker.rb handle_message by default do @broker.ack(delivery_info.delivery_tag) so it's going to be double acknowledged Solution :

  5. Add Boolean in reject and requeue in broker.rb that message rejected

  6. in handle_message before doing default ack check on this boolean

michaelklishin commented 1 year ago

Should this new ivar be reset at some point?

ahmedsaalah commented 1 year ago

https://github.com/ruby-amqp/hutch/blob/87adff64c8c43fa4ec15b258b851d81d12968e15/lib/hutch/worker.rb#L72 In worker.rb handle_message method, every message consumer_instance instantiated so no need to be reset at all

ahmedsaalah commented 1 year ago

Should this new ivar be reset at some point?

@michaelklishin Please let me know if you have any other concerns

ahmedsaalah commented 1 year ago

@michaelklishin Updated .Could you please run workflow again ?Thanks

ahmedsaalah commented 1 year ago

@michaelklishin Hello, Could you please send for me if there is any issue? Thanks in advance