Queue queue = (Queue) context.lookup(TEST_QUEUE);
QueueSender sender = session.createSender(queue);
QueueReceiver receiver = session.createReceiver(queue);
// Send a message that expires in 5 seconds
TextMessage message = session.createTextMessage("5 Second Expiration");
sender.send(message, DeliveryMode.PERSISTENT, 4, 5*1000);
// Send a message that has not expired
message = session.createTextMessage("OK");
sender.send(message);
// Sleep 6 seconds