rabbitmq / rabbitmq-recent-history-exchange

RabbitMQ Recent History Exchange
Other
82 stars 21 forks source link

Only new queues receive exchange history #16

Closed ethagnawl closed 9 years ago

ethagnawl commented 9 years ago

This might 1) be by design or 2) because I'm doing something wrong (probably the case...), but I'm only seeing the message history delivered to new queues.

Here's my code (I'm using the Bunny Ruby client):

@conn = Bunny.new(ENV['CLOUDAMQP_URL'])
@conn.start
@ch = @conn.create_channel
@x = @ch.exchange("video-exchange",
                  type: "x-recent-history",
                  arguments: { 'x-recent-history-length' => 1 })

# will only receive history payload once
queue_name = "queue-1"
@ch.queue(queue_name).bind(@x).subscribe do |_, _, payload|
  puts "!!!!!!!!! '#{payload}' on #{queue_name}"
end

# will always receive history payload
queue_name = "queue-#{SecureRandom.hex}"
@ch.queue(queue_name).bind(@x).subscribe do |_, _, payload|
  puts "!!!!!!!!! '#{payload}' on #{queue_name}"
end
videlalvaro commented 9 years ago

As per the README:

Every time a queue is bound to the exchange it delivers that last 20 messages to them.

So only during queue.bind a queue will receive messages from the history

ethagnawl commented 9 years ago

Thanks for the prompt response! However, I'm still not seeing the behavior as described, so any suggestions would be greatly appreciated.

To expand on the above:

So only during queue.bind a queue will receive messages from the history

Unless this is intended to be only the first time a queue ever binds (which doesn't seem to be the case), I'm not seeing this behavior.

If my client goes down and then re-subscribes using the same queue name (e.g. "queue-1") once it comes back online, it does not receive the history. If it re-subscribes using a dynamic queue name (e.g. "queue-1-18"), it does receive the history.

videlalvaro commented 9 years ago

queue.bind is idempotent at protocol level, so if the binding is there, the second time the command is kinda ignored. On Thu, Nov 19, 2015 at 1:54 PM Pete Doherty notifications@github.com wrote:

Thanks for the prompt response! However, I'm still not seeing the behavior as described, so any suggestions would be greatly appreciated.

To expand on the above:

So only during queue.bind a queue will receive messages from the history

Unless this is intended to be only the first time a queue ever binds (which doesn't seem to be the case), I'm not seeing this behavior.

If my client goes down and then re-subscribes using the same queue name (e.g. "queue-1") once it comes back online, it does not receive the history. If it re-subscribes using a dynamic queue name (e.g. "queue-1-18"), it does receive the history.

— Reply to this email directly or view it on GitHub https://github.com/videlalvaro/rabbitmq-recent-history-exchange/issues/16#issuecomment-158048652 .

ethagnawl commented 9 years ago

Good to know. Thanks! :+1: