Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

purging destinations vs setting message expirations

886634Sep 26 2011 — edited Sep 27 2011
Hi,

Is there a way to automate the process of purging a destination on the broker? For example, I might want to purge the destination before sending it another message so that there is only one message at a time in the destination. Or perhaps the better way to do this is to set the JMSExpiration for each message? Just making sure, but the value the function setJMSExpiration takes is in milliseconds correct?

Thanks!

Comments

Nigel Deakin-Oracle
The JMS specification doesn't offer a way to explicitly purge a destination (delete all its messages), though your chosen JMS provider might off a non-standard way of doing this.

You could of course simply consume all the messages in a loop.

If you want to use message expiration, don't try using setJMSExpiration on the Message. That method is not for the purpose you might think (see the javadocs). Instead use one of the following methods on MessageProducer:

void setTimeToLive(long timeToLive)
Sets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system.

void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive)
Sends a message to a destination for an unidentified message producer, specifying delivery mode, priority and time to live.

timeToLive is in milliseconds.

Nigel
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 25 2011
Added on Sep 26 2011
1 comment
257 views