JMS に関しては、スタンドアロン クライアントから使用する場合と Java EE 環境内で使用する場合とで異なるルールが多数あります。頭に浮かぶことの 1 つは、JMS リスナーを作成する機能です。
そして古い(ただし、1.3仕様からのまだ関連する引用):
... Note that the JMS API creates threads to deliver messages to
message listeners. The use of this message listener facility may be
limited by the restrictions on the use of threads in various
containers. In EJB containers, for instance, it is typically not
possible to create threads. The following methods must not be used by
application components executing in containers that prevent them
from creating threads:
.
- javax.jms.Session method setMessageListener
- javax.jms.Session method getMessageListener
- javax.jms.Session method run
- javax.jms.QueueConnection method createConnectionConsumer
- javax.jms.TopicConnection method createConnectionConsumer
- javax.jms.TopicConnection method createDurableConnectionConsumer
- javax.jms.MessageConsumer method getMessageListener
- javax.jms.MessageConsumer method setMessageListener
.
In addition, use of the following methods on javax.jms.Connection
objects by applications in Web and EJB containers may interfere with the
connection management functions of the container and must not be used:
- setExceptionListener
- stop
- setClientID
A J2EE container may throw a JMSException if the application component
violates these restrictions. ....
Java EE環境では、接続が管理されているため、接続ごとに複数のセッションを作成することは許可されておらず、この方法でそれらを分離しておくことは難しいと思います。しかし、うまくいけば、誰かがより明確な答えを出すことができます.
Java EE 7 用の JMS の新しい 2.0 バージョンでは、その目標の 1 つとして、コア JMS 仕様と Java EE との間の調整が改善され、より明確になっていることに注意してください。こちらをご覧ください: http://jcp.org/en/jsr/detail?id=343