I need to schedule delay messages, so I declare a delay queue DELAY_STAT with x-dead-letter-exchange and x-dead-letter-routing-key which will route to the default exchange to my destination queue STAT.
When I need to schedule a delay message to queue STAT, I publish the message to DELAY_STAT with expiration, and when the message ttl are reached, it will be a dead letter and then be routed to STAT so that it can be consumed.
But I encounter a problem, according to https://www.rabbitmq.com/ttl.html#per-message-ttl-caveats
When setting per-message TTL expired messages can queue up behind non-expired ones until the latter are consumed or expired
which means some short delay message A will be stucked by long delay message B if B is sent earlier.