Rabbitmq message arrival and respond time stamp - rabbitmq

Is there a way to get the timestamp when a message was placed on the queue, from a consumer. Not when it was published, but when it actually made it to the queue.

First, a correction - consumers do not "place" messages on queues, publishers publish messages to exchanges, which then route messages to queues.
Yo can use the RabbitMQ message timestamp community plugin to add a timestamp when a message is published to RabbitMQ.
Please note that RabbitMQ does not guarantee that messages are actually routed to any queues. It's up to you to bind queues correctly to exchanges to ensure that your messages end up where you expect them.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Related

Rabbit MQ - can a message be persisted until all subscribed consumers received it?

I'm having a little trouble figuring if Rabbit MQ can publish a message to a single queue with multiple subscribers, where the message will not get deleted until all subscribers to that queue have gotten the message.
The closest I can find is https://www.rabbitmq.com/tutorials/amqp-concepts.html, where it states:
AMQP 0-9-1 has a built-in feature called message acknowledgements (sometimes referred to as acks) that consumers use to confirm message delivery and/or processing. If an application crashes (the AMQP broker notices this when the connection is closed), if an acknowledgement for a message was expected but not received by the AMQP broker, the message is re-queued (and possibly immediately delivered to another consumer, if any exists).
Does this mean if the queue has more than one subscriber, it will wait until the message is consumed by all subscribers?
You should use multiple queues bound to the same exchange, using the same binding. Then, when a message matches the binding, it will be delivered to all queues, which presumably each have a consumer.
If you have multiple consumers on a single queue, RabbitMQ will round-robin deliveries among those consumers (which is not what you want).
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

RabbitMQ dead letter queue housekeeping

I have a RabbitMQ instance that has an exchange, a regular queue and a dead letter queue. Rejected messages are moved from the regular queue to the dead letter queue.
These rejected messages are not important to me because any missed data is supplied again the next day.
Currently I regularly purge the messages in the dead letter queue, but I want to automate it.
How do I do that?
All the tutorials that I've found so far explain how to expire messages using policies or tags, by which they are moved from the regular queue to the dead letter queue. But none of these tutorials talk about the situation where you want to expire messages that are already in the dead letter queue.
I just want to get rid of those messages, not save them to reprocess later.
How do I do that?
You should set a message TTL for your dead-letter queue -
https://www.rabbitmq.com/ttl.html
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

RabbitMQ Fanout Exchange Explanation

Assuming there is a RabbitMQ fanout exchange and 1,000,000 (or any kind of number) consumers are subscribed to it.
Now the exchange publishes a message. Will all consumers receive the message at the same (meaning exactly) time? Or could there be some millisecond time delay between the first and last consumer receiving the message.
In particular I am interested in the logic the RabbitMQ Fanout exchange publishes the message to the subscribed consumers.
Is is some sort of first come first serve logic, i.e. whoever subscribes first also gets the message first? Or is it random? I couldn't find anything regarding this in the documentation.

RabbitMQ - Will the same message be delivered to consumers on separate connections

If I have and exchange with a single queue bound to it. I have two processes each with their own connection. Each connection has its own consumer which is consuming messages from that single queue.
Is it possible that when a message is placed onto the queue, both consumers could be delivered the same message?
Pre-fetch seems to apply across consumers on a single channel, or connection if the global flag is set. What happens with consumers across multiple connections
No. Messages are always round-robin delivered to multiple consumers on the same queue.
One solution is to have two queues bound to the same exchange using the same routing key if you need messages to go to both consumers.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Discover queues which messages waiting in RabbitMQ

I'd like to detect situation, when there is new message in any queue.
Currently I'm using Management API to list queues with ready messages via /api/queues/[vhost] endpoint polling. This works, but API reports data with several-second delay.
Is there any way to poll real-time queues' data or be notified about new message in any queue?
notified about new message in any queue?
You could consume from the queue with a prefetch value of 1.
Or, you can use the Basic.Get method and poll the queue.
In either case, a message will be delivered that you will have to process or reject to re-queue it.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.