Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » jms » asf » [javadoc | source]
org.jboss.jms.asf
public class: StdServerSession [javadoc | source]
java.lang.Object
   org.jboss.jms.asf.StdServerSession

All Implemented Interfaces:
    Runnable, javax.jms.ServerSession, javax.jms.MessageListener

An implementation of ServerSession.

Created: Thu Dec 7 18:25:40 2000

Field Summary
static  Logger log    Instance logger. 
Constructor:
 StdServerSession(StdServerSessionPool pool,
    Session session,
    XASession xaSession,
    MessageListener delegateListener,
    boolean useLocalTX,
    XidFactoryMBean xidFactory) throws JMSException 
    Create a StdServerSession .
    Parameters:
    pool - The server session pool which we belong to.
    session - Our session resource.
    xaSession - Our XA session resource.
    delegateListener - Listener to call when messages arrives.
    useLocalTX - Will this session be used in a global TX (we can optimize with 1 phase commit)
    Throws:
    JMSException - Transation manager was not found.
    JMSException - Description of Exception
    exception: JMSException - Description of Exception
Method from org.jboss.jms.asf.StdServerSession Summary:
close,   getSession,   onMessage,   recycle,   run,   start
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jboss.jms.asf.StdServerSession Detail:
  void close() 
    Called by the ServerSessionPool when the sessions should be closed.
 public Session getSession() throws JMSException 
    Returns the session.

    This simply returns what it has fetched from the connection. It is up to the jms provider to typecast it and have a private API to stuff messages into it.

 public  void onMessage(Message msg) 
    Will get called from session for each message stuffed into it. Starts a transaction with the TransactionManager and enlists the XAResource of the JMS XASession if a XASession was available. A good JMS implementation should provide the XASession for use in the ASF. So we optimize for the case where we have an XASession. So, for the case where we do not have an XASession and the bean is not transacted, we have the unneeded overhead of creating a Transaction. I'm leaving it this way since it keeps the code simpler and that case should not be too common (JBossMQ provides XASessions).
  void recycle() 
    This method is called by the ServerSessionPool when it is ready to be recycled intot the pool
 public  void run() 
    Runs in an own thread, basically calls the session.run(), it is up to the session to have been filled with messages and it will run against the listener set in StdServerSessionPool. When it has send all its messages it returns.
 public  void start() throws JMSException 
    Start the session and begin consuming messages.