Here is an updated proposal for this issue. You'll recall the issue here is whether the three createSession methods
*must* throw an exception if the application tries to create two sessions for the same connection in a Java EE web or
EJB application.
This updated proposal would relax this requirement from *must* to *should*, to reflect the less strict wording in the
Java EE 6 specification and avoid introducing an incompatible change to createSession(boolean, int).
I am proposing to leave unchanged the requirement for the simplified API to throw an exception in the same
circumstances. This requirement is already in the javadocs (and enforced by CTS). However the text in section 12.2 of
the specification is inconsistent so I am proposing to change it to match the javadocs.
In both cases, the spec will continue to say that the application *must not* do these things, since this is the wording
used in Java EE 6. Note that this is an obligation on the application, and not on the JMS implementation.
You can see a nicely-formatted version of this proposal at
https://java.net/jira/browse/JMS_SPEC-157?focusedCommentId=382448
Nigel
JMS specification section 12.2 "Restrictions on the use of JMS API in the Java EE web or EJB container"
-------------------------------------------------------------------------------------------------------
Existing text:
Applications running in the Java EE web and EJB containers must not attempt
to create more than one active (not closed) Session object per connection.
* If an application attempts to use the Connection object’s createSession
method when an active Session object exists for that connection then a
JMSException should be thrown.
* If an application attempts to use the JMSContext object’s createContext
method then a JMSRuntimeException should be thrown, since the first
JMSContext already contains a connection and session and this method would
create a second session on the same connection.
Replacement test (changed words *thus*)
Applications running in the Java EE web and EJB containers must not attempt
to create more than one active (not closed) Session object per connection.
* If an application attempts to use the Connection object’s createSession
method when an active Session object exists for that connection then a
JMSException should be thrown.
* If an application attempts to use the JMSContext object’s createContext
method then a JMSRuntimeException *must* be thrown, since the first
JMSContext already contains a connection and session and this method would
create a second session on the same connection.
JMS specification section 2.8.2. "Key features of the simplified API":
----------------------------------------------------------------------
Existing text
Applications running in the Java EE web and EJB containers are not permitted
to create more than one active session on a connection...
Modified text: (changed words *thus*)
Applications running in the Java EE web and EJB containers *must not*
create more than one active session on a connection...
Javadoc for Connection.html#createSession():
--------------------------------------------
Existing text
Applications running in the Java EE web and EJB containers must not attempt to
create more than one active (not closed) Session object per connection. If
this method is called in a Java EE web or EJB container when an active Session
object already exists for this connection then a JMSException will be thrown.
Replacement text:
Applications running in the Java EE web and EJB containers must not attempt to
create more than one active (not closed) Session object per connection. If
this method is called in a Java EE web or EJB container when an active Session
object already exists for this connection then a JMSException *may* be thrown.
Javadoc for Connection.html#createSession(int):
-----------------------------------------------
Existing text
Applications running in the Java EE web and EJB containers must not attempt to
create more than one active (not closed) Session object per connection. If
this method is called in a Java EE web or EJB container when an active Session
object already exists for this connection then a JMSException will be thrown.
Replacement text:
Applications running in the Java EE web and EJB containers must not attempt to
create more than one active (not closed) Session object per connection. If
this method is called in a Java EE web or EJB container when an active Session
object already exists for this connection then a JMSException *may* be thrown.
Javadoc for Connection.html#createSession(boolean, int):
--------------------------------------------------------
Existing text
Applications running in the Java EE web and EJB containers must not attempt to
create more than one active (not closed) Session object per connection. If
this method is called in a Java EE web or EJB container when an active Session
object already exists for this connection then a JMSException will be thrown.
Replacement text:
Applications running in the Java EE web and EJB containers must not attempt to
create more than one active (not closed) Session object per connection. If
this method is called in a Java EE web or EJB container when an active Session
object already exists for this connection then a JMSException *may* be thrown.