javajmstibco-ems

TIBCO-EMS: Set message delay based on JMS message header


I need different delay for different messages based on special conditions. Is there a way to set the delivery delay in a message header using TIBCO EMS like in ActiveMQ?

ActiveMQ example:

MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage("test msg");
    
if (condition) {
   long time = 60 * 1000;
   message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, time);
}
producer.send(message);

Solution

  • If Tibco EMS supports JMS 2 then you can use javax.jms.MessageProducer#setDeliveryDelay(long):

    MessageProducer producer = session.createProducer(destination);
    TextMessage message = session.createTextMessage("test msg");
        
    if (condition) {
       long time = 60 * 1000;
       producer.setDeliveryDelay(time);
    }
    producer.send(message);