JMS应用程序客户端可以创建多个活动会话,而Web / ejb组件不能?

| 我正在阅读JMS的JEE5教程。 而且我很难理解这个“一般规则”的原因:   Java EE平台规范中的一条通用规则适用于在EJB或Web容器中使用JMS API的所有Java EE组件:      Web和EJB容器中的应用程序组件不得为每个连接尝试创建多个活动(未关闭)的Session对象。      此规则不适用于应用程序客户端。 为什么它不适用于应用程序客户端,而不适用于Web / EJB组件?     
已邀请:
在独立客户端和Java EE环境中使用JMS时,有许多关于JMS的规则有所不同。想到的一件事是创建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版本在核心JMS规范和Java EE之间实现了更好,更清晰的对齐,这是其目标之一。看到这里:http://jcp.org/en/jsr/detail?id=343     

要回复问题请先登录注册