jsr343-experts@jms-spec.java.net

[jsr343-experts] Re: (JMS_SPEC-52) Clarify that a message may be sent using a different session from that used to create the message

From: John D. Ament <john.d.ament_at_gmail.com>
Date: Thu, 22 Sep 2011 09:32:25 -0400

Noting the Connection requirement, it makes sense to be included. I agree
about the comments about the ambiguity, but it seems its not perfectly
clear. This should ultimately become a TCK test case, so I figure more
precision the better.

John

On Thu, Sep 22, 2011 at 7:14 AM, Nigel Deakin <nigel.deakin_at_oracle.com>wrote:

> John,
>
>
> On 22/09/2011 02:13, John D. Ament wrote:
>
> Nigel,
>
> Is it enough to say that the same Session is not required, but also a
> correlation back to Connection? This is essentially implied in an EE world,
> but for SE it may differ.
>
>
> I hadn't thought of that (but then I hadn't thought the existing spec was
> ambiguous). Yes, it would be worth spelling that out in the clarification.
> I've updated the JIRA issue accordingly.
>
> Nigel
>
>
>
> John
>
> On Wed, Sep 21, 2011 at 7:45 AM, Nigel Deakin <nigel.deakin_at_oracle.com>wrote:
>
>> I have raised this JIRA issue:
>> http://java.net/jira/browse/JMS_SPEC-52
>>
>> You may remember discussing this some time ago. I was surprised to
>> discover that we had interpreted the spec differently, and there seemed to
>> be general consensus that the spec should be clarified as described below.
>>
>> This change also makes it easier to define standard annotations for
>> injecting message objects, since there would no longer be any need to worry
>> about which session was used to create an injected message.
>>
>> Comments, please..
>>
>>
>> Here is the description in JIRA
>> -------------------------------
>>
>> The JMS 1.1 API defines how a JMS message object is created using one of
>> the following methods on a Session:
>>
>> Message createMessage()
>> BytesMessage createBytesMessage()
>> MapMessage createMapMessage()
>> ObjectMessage createObjectMessage()
>> ObjectMessage createObjectMessage(java.io.Serializable object)
>> StreamMessage createStreamMessage()
>> TextMessage createTextMessage()
>> TextMessage createTextMessage(java.lang.String text)
>>
>> The following question has been raised:
>>
>> Can a message be sent using a MessageProducer that was created from a
>> different Session than was used to create the message?
>>
>> This is not stated explicitly in the specification, and discussions within
>> the JSR 343 Expert group show that different individuals have come to
>> different conclusions on this issue.
>>
>> My own interpretation is that a MessageProducer must be able to send a
>> javax.JMS.Message irrespective of how it was created. It might have been
>> created using Session.createMessage(), or it may have been received by a
>> MessageConsumer.
>>
>> Furthermore, Section 3.12 of the JMS 1.1 specification states explicitly
>> that a MessageProducer must be able to send a message that was created using
>> a different JMS provider, and which would therefore have used a different
>> session:
>>
>> "A provider must be prepared to accept, from a client, a message whose
>> implementation is not one of its own. A message with a 'foreign'
>> implementation may not be handled as efficiently as a provider's own
>> implementation; however, it must be handled."
>>
>> Despite this, there is a widespread view within the JMS community that for
>> messages created within the same JVM by the same JMS provider, the session
>> used to create the message must be the same as that used to send it.
>>
>> It is therefore proposed that the JMS specification be clarified that
>> there is no such restriction, and that a MessageProducer can be used to send
>> any message object
>>
>> * irrespective of which session was used to create it,
>> * irrespective of whether the message was created within this JVM or
>> received from a JMS destination, and
>> * irrespective of whether the MessageProducer and message are implemented
>> by the same or different JMS providers.
>>
>>
>>
>