users@jms-spec.java.net

[jms-spec users] [jsr343-experts] Re: State of a message in a producer after send

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Fri, 13 Dec 2013 17:37:54 +0000

On 13/12/2013 16:45, Matthew White wrote:
> After a message has been received by a MessageConsumer - the state of the message is in read-only state. There's
> nothing that I can see in the JavaDoc/Spec that indicates what the state of the message in the thread that has done a
> send. So for example - in this pseudo-code
>
> {
> TextMessage tm = session.createTextMessage();
> producer.send(tm);
> // what state is TM in now? Read-only, write-only?
> }

The spec requires a message received by receive() or onMessage as being in read-only mode, and explains that this is to
allow providers to optimise the implementation of received messages.

I think a message may only be put into read-only mode in the cases explicitly described in the spec. The message
returned by session.createTextMessage() must be writeable, and send() mustn't change the message to read-only mode.

You may have seen the discussion yesterday about whether send() was allowed to change a message from read-only to
writeable mode. I think that's OK but the spec isn't explicit on that.

>
> Similarly if a CompletionListener is set - when that gets called - is the message object that is passed read or write-only?

The message object passed to the completion listener is "the message that was sent." I'd expect this to be the same
object that was passed to send().

Nigel