Menu Close
Settings Close

Language and Page Formatting Options

17.6.8. Set Message Expiry


Using HornetQ Core API, the expiration time can be set directly on the message. For example:

// message will expire in 5000ms from now
message.setExpiration(System.currentTimeMillis() + 5000);
JMS MessageProducer

JMS MessageProducer includes a TimeToLive parameter which controls message expiry for the messages it sends:

// messages sent by this producer will be retained for 5s (5000ms) before expiration           
Expired messages which are consumed from an expiry address have the following properties:
A string property containing the original address of the expired message.
A long property containing the actual expiration time of the expired message.