jsr343-experts@jms-spec.java.net

[jsr343-experts] Re: (JMS_SPEC-43) New API to send a message with async acknowledgement from server

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Tue, 20 Sep 2011 16:55:20 +0100

On 05/08/2011 17:35, Nigel Deakin wrote:
> I have logged this JIRA issue:
> http://java.net/jira/browse/JMS_SPEC-43
>
> This issue was raised by Clebert, though the wording below is my own. It was also mentioned in Tom's longer list of
> proposals.
>
> Comments, please!

I have received no comments on this. Can I at least have feedback from Clebert and Tom who raised this initially?

Tim Fox has suggested an alternative to setAcknowledgeListener(), which is to pass in the callback object in the send()
call. I think this is a good idea, so I'd like to request comments on which is better.

There would be two new methods:

send(Message message,
    javax.jms.AcknowledgeListener acknowledgeListener )

send(Message message, int deliveryMode, int priority, long timeToLive,
    javax.jms.AcknowledgeListener acknowledgeListener)

This would have the same behaviour as the corresponding existing send methods except that that they would return without
blocking until an acknowledgement has been received from the server. When the acknowledgement is received, the callback
method on the supplied AcknowledgeListener is invoked.

These methods allow a different callback object to be specified for each message that is sent. This allows applications
to can pass in an anonymous class with message-specific state, which would not be possible if the same callback object
were used for multiple messages.

The main drawback is that it doubles the number of send() methods from two to four.

(I have updated the JIRA issue with this alternative suggestion)

Nigel


>
> ------------------
>
> This is a proposal for a new API which will send a message and return immediately without blocking until an
> acknowledgement has been received from the server. Instead, when the acknowledgement is received, an asynchronous
> callback will be invoked.
>
> Here is a suggested API:
>
> There would be a new method on {{javax.jms.MessageProducer}}:
>
> public void setAcknowledgeListener(AcknowledgeListener listener);
>
> This would change the behaviour of any subsequent call to any of the four {{send}} methods so that they would return
> without blocking until an acknowledgement has been received from the server. When the acknowledgement is received, the
> callback method on the {{AcknowledgeListener}} is received.
>
> This feature will only be available for non-transacted sessions. if {{setAcknowledgeListener}} was called on a
> transacted session then a {{javax.jms.IllegalStateException}} would be thrown.
>
> package javax.jms;
> import javax.jms.Message;
>
> public interface AcknowledgeListener {
> public void onAcknowledge(Message message);
> }
>
> ------------------