Java Funs
Java Funs

Reputation: 31

How to drop queue message when there is no consume?(ActiveMQ)

Use ActiveMQ : Senario: Server will send many messages to client through Queue. However ,i nedd to drop the message in the queue if there is no consumer(client)

Thanks in advance!

Upvotes: 3

Views: 1678

Answers (2)

Tim
Tim

Reputation: 2027

Set a JMSExpiration on each message for some duration (30 seconds? 5 minutes?), and then any message that's not consumed after that amount of time (whether because there's no consumer or because the consumer's running behind) will be sent to the DLQ. Or if you don't want it in the DLQ, then configure the dead letter strategy to set processExpired=false or use a Discarding DLQ Plugin, both documented at http://activemq.apache.org/message-redelivery-and-dlq-handling.html.

Upvotes: 1

Claus Ibsen
Claus Ibsen

Reputation: 55540

You can use non persistent messaging and the message is dropped if there is no active consumers.

Another alternative could be to use message expiry, so the message expires after X period, if they are not consumed from the queue.

Upvotes: 2

Related Questions