17.6.8. 设置消息过期
简介
通过 HornetQ Core API,过期时间可以直接在消息上设置。例如:
// message will expire in 5000ms from now message.setExpiration(System.currentTimeMillis() + 5000);
// message will expire in 5000ms from now
message.setExpiration(System.currentTimeMillis() + 5000);
JMS
MessageProducer
JMS MessageProducer
包含了一个 TimeToLive
参数,它控制发送的消息的过期:
// messages sent by this producer will be retained for 5s (5000ms) before expiration producer.setTimeToLive(5000);
// messages sent by this producer will be retained for 5s (5000ms) before expiration
producer.setTimeToLive(5000);
从过期地址消费的过期消息具有下列属性:
- _HQ_ORIG_ADDRESS
包含过期消息的原始地址的字符串型属性
- _HQ_ACTUAL_EXPIRY
包含过期消息的实际过期时间的长整型属性。