jsr343-experts@jms-spec.java.net

[jsr343-experts] (JMS_SPEC-44) New API to specify delivery delay

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Mon, 08 Aug 2011 12:09:15 +0100

I have logged this JIRA issue:
http://java.net/jira/browse/JMS_SPEC-44

This issue was raised by Emran and Tom, though the wording is my own.

I've modelled the API proposals below on the existing API for time-to-live/expiration time since I think a consistent
API is important in making it easy to understand.

Please share your views on (1) the general desirability of such a feature and (2) the actual API proposed.

Tom/Emran (and others): it would be helpful if you could give some more information on what this feature (which I know
some JMS providers already offer) would be used for.

Nigel

------------------------------------------------------------------------------
This is a proposal to allow a JMS client to specify a delivery delay when sending a message. If a delivery delay has
been specified for a message then the message will not be delivered to any consumers until after the delivery delay has
expired.

This feature has also been referred to as "delivery time", "timed messages" or "future messages".

The API for delivery delay is intended to be similar to that for the existing timeToLive property of a MessageProducer
and the corresponding JMSExpiration header field of a Message.

There would be new methods on javax.jms.MessageProducer:

*** public void setDeliveryDelay(long deliveryDelay) throws javax.jms.JMSException;

This sets the minimum length of time in milliseconds from its dispatch time
that a produced message should be retained by the messaging system before
delivery to a consumer.

If the delivery delay is greater then the time to live then the message
will always be expired before delivery.

*** public long getDeliveryDelay()

Returns the minimum length of time in milliseconds from its dispatch time
that a produced message should be retained by the messaging system before delivery to a consumer.

There would be new methods on javax.jms.Message:

*** public long getJMSDeliveryTime() throws JMSException

Returns the message's delivery time.

When a message is sent, the JMSDeliveryTime header field is left unassigned.
After completion of the send or publish method, it holds the minimum delivery time time
of the message. This is the sum of the delivery delay value specified by the client and
the GMT at the time of the send or publish.

When the delivery delay is specified as zero, JMSDeliveryTime is set to zero to indicate
that there is no delivery delay.

A provider must not deliver a message before the defined delivery time has been reached.

*** public void setJMSDeliveryTime(long deliveryTime) throws JMSException

Sets the message's delivery time.

JMS providers set this field when a message is sent.
This method can be used to change the value for a message that has been received.

Note that this public method is not intended for use by clients but is needed to allow providers to set this value on a
message implemented by a different provider. There is a separate issue to clarify this behaviour:
http://java.net/jira/browse/JMS_SPEC-34