ServerSession (Java EE 5)

Java EE API


javax.jms Interface ServerSession


public interface ServerSession


ServerSession 对象是应用服务器对象,服务器使用该对象将线程与 JMS 会话关联(可选)。

ServerSession 实现两个方法:

  • getSession - 返回 ServerSession 的 JMS 会话。
  • start - 开始执行 ServerSession 线程,并导致 JMS 会话的 run 方法执行。

JMS 提供者实现的 ConnectionConsumer 使用 ServerSession 处理一个或多个到达的消息。它通过从 ConnectionConsumerServerSessionPool 获取 ServerSession;获取 ServerSession 的 JMS 会话;使用消息加载 JMS 会话;然后启动 ServerSession 做到这一点。

在大多数情况下,ServerSession 会将它提供的某个对象注册为 ServerSession 的线程运行对象。ServerSessionstart 方法将调用线程的 start 方法,从而启动新线程,然后从该线程调用 ServerSession 的运行对象的 run 方法。此对象将执行一些内务处理,然后调用 Sessionrun 方法。当 run 返回时,ServerSession 的运行对象可能将 ServerSession 返回到 ServerSessionPool,然后再次开始循环。

注意,JMS API 没有架构 ConnectionConsumer 使用消息加载 Session 的方式。由于 ConnectionConsumerSession 都是由相同的 JMS 提供者实现的,因此它们可以使用专有机制来完成加载。

英文文档:

A ServerSession object is an application server object that is used by a server to associate a thread with a JMS session (optional).

A ServerSession implements two methods:

  • getSession - returns the ServerSession's JMS session.
  • start - starts the execution of the ServerSession thread and results in the execution of the JMS session's run method.

A ConnectionConsumer implemented by a JMS provider uses a ServerSession to process one or more messages that have arrived. It does this by getting a ServerSession from the ConnectionConsumer's ServerSessionPool; getting the ServerSession's JMS session; loading it with the messages; and then starting the ServerSession.

In most cases the ServerSession will register some object it provides as the ServerSession's thread run object. The ServerSession's start method will call the thread's start method, which will start the new thread, and from it, call the run method of the ServerSession's run object. This object will do some housekeeping and then call the Session's run method. When run returns, the ServerSession's run object can return the ServerSession to the ServerSessionPool, and the cycle starts again.

Note that the JMS API does not architect how the ConnectionConsumer loads the Session with messages. Since both the ConnectionConsumer and Session are implemented by the same JMS provider, they can accomplish the load using a private mechanism.

Version:
1.0 - 9 March 1998
Author:
Mark Hapner, Rich Burridge
See Also:
ServerSessionPool, ConnectionConsumer

Method Summary
 Session
 void
 

Method Detail

public Session getSession() throws JMSException
返回 ServerSessionSession。此会话必须是由将消息分派给它的那个 Connection 创建的 Session。提供者将一个或多个消息分配给 Session,然后调用 ServerSession 中的 start
return 服务器会话的会话
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取与此 ServerSession 关联的会话。
英文文档:

getSession

Session getSession()
                   throws JMSException
Return the ServerSession's Session. This must be a Session created by the same Connection that will be dispatching messages to it. The provider will assign one or more messages to the Session and then call start on the ServerSession.

Returns:
the server session's session
Throws:
JMSException - if the JMS provider fails to get the associated session for this ServerSession due to some internal error.

public void start() throws JMSException
导致调用 Sessionrun 方法来处理刚分配给它的消息。
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法启动服务器会话来处理消息。
英文文档:

start

void start()
           throws JMSException
Cause the Session's run method to be called to process messages that were just assigned to it.

Throws:
JMSException - if the JMS provider fails to start the server session to process messages due to some internal error.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!