Search

Chapter 13. Scheduling Messages

download PDF

You can specify a time in the future, at the earliest, for a message to be delivered. This can be done by setting the _AMQ_SCHED_DELIVERY scheduled delivery property before the message is sent.

The specified value must be a positive long that corresponds to the time in milliseconds for the message to be delivered. Below is an example of sending a scheduled message using the JMS API.

// Create a message to be delivered in 5 seconds
TextMessage message = session.createTextMessage("This is a scheduled message message that will be delivered in 5 sec.");
message.setLongProperty("_AMQ_SCHED_DELIVERY", System.currentTimeMillis() + 5000);
producer.send(message);

...

// The message will not be received immediately, but 5 seconds later
TextMessage messageReceived = (TextMessage) consumer.receive();

Scheduled messages can also be sent using the core API by setting the _AMQ_SCHED_DELIVERY property before sending the message.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.