rabbitmq Per-Queue Message TTL can't work - rabbitmq

I want to discard the messages in the rabbitmq queues when they are not consumed after 3 minutes.
According to official doc http://www.rabbitmq.com/ttl.html ;
rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues
I just set this command, but it don't work as I expect.
If the policy is called when the queues are empty,then the incoming messages will be discarded after expired. Otherwise, the old messages and new messages will be keep in the queues.
Any guys know why ?

Related

RabbitMQ auto-delete queues with timeouts

I have a k8s service, using rabbitMQ as message broker.
I want to be able to delete a specific queue if the service deployment which may have multiple pods is stopped.
Reading the documentation RabbitMq Queues Docs I found that the best case for me in this case is to use the auto-deleted property of the queue.
Is there any option so the auto-deleted queue will not be deleted immediately after the clients are disconnected, instead to wait some seconds to wait for reconnection ?

How to see RabbitMQ messages

Can't view rabbitmq queue messages after using the get messages command.
rabbitmqadmin get queue='queue_name' -H localhost -P 15672 -u rmq -p rmq --vhost=/ count=100
Queue count shows 100 messages, cant use the above command again to see the messages.
I would suggest to read https://www.rabbitmq.com/getstarted.html to understand how rabbitmq works.
The command get consumes the messages so you can't consume them anymore.
If you want to consume the same messages multi-times you can use the stream queue type.
When rabbitMq consumer consumes a mensagem from a queue the same will be deleted from the queue. If you just want to see the message you can log to the RabbitMQ Managment and read the messages, if they're not serialized. But if you want to consume the same message for some reason multiple times read the part of streams queue on the documentation.

How to acknowledge all the unacked messages present in a RabbitMQ queue using REST API from Mule 3

I have to acknowledge all the unacknowledged message and make the count zero. If the message is in ready so the using the purge requester (DELETE http://localhost:8767/api/queues/vhost/name/contents) I am able to purge and remove the messages but if it is in unacked then this purge is not working or count still showing in the unacked section.
Kindly suggest how to use the REST API of RabbitMQ to ACK all the messages in the queue and make the count as zero.
you can ack them or purge queue in rabbitmq management

rabbitmq quorum Queue ensure retry if data is lost

I read that Quorum Queue does not support ttl for both messages and Queues.
The producer in my system maintains state in database with message "READY_TO_SUBMIT" and then sends it to cluster of Quorum queue. In case the rabbitmq Queue crashes or for any reason the message is not delivered to consumer. How will my producer know that it should retry the message again.
In case of mirrored queue I assume I can put a ttl and then after the ttl gets over my producer can retry again if that status is not updated by consumer for "READY_TO_SUBMIT" to "SUBMITTED".
Your producers absolutely must use publisher confirms correctly: https://www.rabbitmq.com/confirms.html
Please see the detailed tutorial here: https://www.rabbitmq.com/tutorials/tutorial-seven-java.html
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Set a message limit to the RabbitMQ queue

I use both AMQP and MQTT protocols in RabbitMQ. I use the pica library for AMQP and the paho library for MQTT. I can give a message limit when I define the tail with Pika (x-max-length). But when I use paho for MQTT, I cannot limit the message. If I give the queue 50 message limit in the AMQP, the number of messages in the queue will never exceed 50. Why can't I do this on MQTT, is there another way I can set a message limit?
https://www.youtube.com/watch?v=xcpxGJuOyBQ
There is a sample video. The broadcaster sends the message fast, but because the receiver is slow, too many messages accumulate in the broker. I always want to receive the last message.
Using rabbitmqctl you can directly set maximum length for queue using policies instead of doing that using client libraries.
Example:
rabbitmqctl set_policy my-pol "^one-meg$" '{"max-length-bytes":1048576}' --apply-to queues
Take a look on Queue Length Limit in official docs.