Question

JBoss EAP 6.2 with the built-in HornetQ (2.3.12.Final)

_HQ_SCHED_DELIVERY, the property that indicates the delivery delay is set on the message prior to sending, but the message is picked up immediately by the listener. Both the sender and the receiver are on the same machine (as a matter of fact, in the same app) so a clock difference cannot be responsible.

jmsTemplate.send(myQueue, new MessageCreator() {
    @Override
    public Message createMessage(javax.jms.Session session) throws JMSException {
        MyMessageClass myMessageObject = new MyMessageClass(); //attributes omitted
        Message message = session.createObjectMessage(myMessageObject);
        message.setLongProperty("_HQ_SCHED_DELIVERY", 60000); //should delay a minute
        return message;
    }
});

The name and type of the property is correct according to https://docs.jboss.org/hornetq/2.3.0.CR2/docs/user-manual/html/scheduled-messages.html

Was it helpful?

Solution

You got it wrong. It's delivery time, not delay!

You should set System.currentTimeMillis() + 60000 for the proper usage.

Correct use is:

message.setLongProperty("_HQ_SCHED_DELIVERY", 
    System.currentTimeMillis() + 60000); //should delay a minute

OTHER TIPS

From the official resource: at the HornetQ Manual :

The specified value must be a positive long corresponding to the time the message must be delivered (in milliseconds).

So, yes; you set this to a millisecond representation of when this should be delivered. So a delay will be current time plus delay, or a specific time just create a Date object for that time and fire that through.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top