twingly / twingly-amqp

:bus: Ruby gem for RabbitMQ subscribing and publishing
0 stars 0 forks source link

All messages are acked in Subscription#subscribe #13

Closed jage closed 8 years ago

jage commented 8 years ago

When we add an exception handler all messages are "acknowledged". We need to be able to re-queue messages for queue where we can't lose messages.

roback commented 8 years ago

We could just add an argument to Subscribe.new (requeue_on_error: false) or should the requeue be set based on the exception?

(how to requeue: http://www.rubydoc.info/github/ruby-amqp/bunny/Bunny/Channel#reject-instance_method)

roback commented 8 years ago

Im thinking of creating a Message class which subscription.subscribe gives to the block, instead of only the payload (which it is now).

subscription.subscribe do |message|
  message         # => Twingly::AMQP::Message
  message.payload # => { url: "http://..." }

  message.ack     # default
  message.reject
  message.discard
end

This way it will be easier to expose the messages metadata and delivery_info (see the docs).

jage commented 8 years ago

I like it.

roback commented 8 years ago

Hmm... How to handle multiple "messages" in one payload: https://github.com/twingly/zambezi/commit/432bde61e1bd8f0014f6c76405fa01d46149f4ef ?

roback commented 8 years ago

Found it: https://github.com/twingly/zambezi/blob/master/lib/binlog/queue.rb#L99-L101 :smile: