Read this https://www.rabbitmq.com/ttl.html
A TTL can be specified on a per-message basis, by setting the
expiration field in the basic AMQP class when sending a basic.publish.
The value of the expiration field describes the TTL period in
milliseconds. The same constraints as for x-message-ttl apply. Since
the expiration field must be a string, the broker will (only) accept
the string representation of the number.
Suppose you set Expiration
time = 1000
If no one consumes the message within 1 second the message will be dropped.
You can handle the "dropped" messages using https://www.rabbitmq.com/dlx.html.
if you don't set the Expiration
the message remains to the queue for ever (if there aren't consumers).
EDIT
Added the comment by theMayer
The messages are not dropped until they reach the head of the queue - therefore, if a non-expiring message exists prior to the message in the queue, no messages will self-delete until the non-expiring message is consumed.
read also this post