News for hackers. Stuff that matters.
Re:My RabbitMQ setup for notifications by eterm on Friday July 26, 2013 @03:35PM (#6110051)
Is it possible to have it so that it's fanout but a "die on first receive"?

i.e. If I send out a notification I don't care if it's my phone, my desktop or my laptop that gets the notification, but if one of those devices gets the message (race conditions not withstanding) then I don't want the other devices to get the message.

Or is it the case that if they weren't online they'd not be currently subscribed so they wouldn't naturally get it? In which case what happens if there are no current subscribers?

Re:My RabbitMQ setup for notifications by rickhanlonii on Friday July 26, 2013 @06:08PM (#6110880)
You can use a direct queue for this. Just have the phone, desktop, laptop, et. al. consume from the same queue. Rabbit gives out messages in a round-robin to the listening consumers, and the first to pickup the message is the only queue to get the message.

Then, let's say there's an error in the phone notification and you want to pass it back and let the next service try. This is where Rabbit's ACK system can come into play: you can setup rabbit to wait for an ACK response from a consumer acknowledging that the message was received and processed. If the consumer errors, you can return the message back to Rabbit and it will be given to the next consumer in line (which is the next consumer not busy).

If a service is not online, then they won't be consuming from the queue, so they won't get the message. If there are no consumers, then the message will wait in the queue until a consumer binds to consume the message.

Hope this makes sense!

Re:My RabbitMQ setup for notifications by jeffasinger on Friday July 26, 2013 @03:49PM (#6110148)
You could share one queue amongst several devices, and Rabbit will ensure that only one device gets the message (with proper acking on the subscriber side).

If a message gets sent to an exchange that has no queues attached, typically it will get sent to a dead letter exchange.

Edit: Most Rabbit client libraries have two different modes, one where you automatically acknowledge any message that is received, and another mode where you must explicitly acknowledge that you've received the message.

Re:My RabbitMQ setup for notifications by silasb on Friday July 26, 2013 @03:47PM (#6110136)
I was wondering about this also. I'm not sure if there is an acknowledgement system built into RabbitMQ, but it sounds like that is what would be needed for this to happen.
Re:My RabbitMQ setup for notifications by rickhanlonii on Friday July 26, 2013 @06:10PM (#6110894)
By default any message picked up from a queue by a consumer is removed (acknowledged), but you can configure the exchange so that it waits for an ACK from the consumer before removing the message. This gives the consumer the ability to return the message to the queue, but is dangerous because Rabbit will never stop waiting on the consumer to respond.