JMS 会话线程影响

JMS session thread implications

什么意思:

A Session object is a single-threaded context for producing and consuming messages

为什么 Session 扩展 Runnable? 这是否意味着当我们创建一个新的会话对象时,总是会启动一个新的应用程序级线程?

我需要帮助来理解这一点。

Does that imply that when we create a new session object, a new application level thread is always started?

不,这意味着当开始一个新线程时你应该为它获取一个新的Session。它说在 same place you were looking:

If a client desires to have one thread produce messages while others consume them, the client should use a separate session for its producing thread.

Once a connection has been started, any session with one or more registered message listeners is dedicated to the thread of control that delivers messages to it. It is erroneous for client code to use this session or any of its constituent objects from another thread of control. The only exception to this rule is the use of the session or connection close method.