User: starksm 
  Date: 01/12/13 05:32:05

  Modified:    src/main/org/jboss/jms/asf StdServerSession.java
                        StdServerSessionPool.java
  Log:
  Use trace level logging for the per message methods
  
  Revision  Changes    Path
  1.11      +90 -84    jboss/src/main/org/jboss/jms/asf/StdServerSession.java
  
  Index: StdServerSession.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/jms/asf/StdServerSession.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StdServerSession.java     2001/12/12 22:12:18     1.10
  +++ StdServerSession.java     2001/12/13 13:32:05     1.11
  @@ -31,7 +31,7 @@
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Peter Antman</a> .
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a> .
  - * @version   $Revision: 1.10 $
  + * @version   $Revision: 1.11 $
    */
   public class StdServerSession
      implements Runnable, ServerSession, MessageListener
  @@ -40,39 +40,39 @@
       * Instance logger.
       */
      static Logger log = Logger.getLogger(StdServerSession.class);
  -
  +   
      /**
       * The server session pool which we belong to.
       */
      private StdServerSessionPool serverSessionPool;
  -
  +   
      /**
       * Our session resource.
       */
      private Session session;
  -
  +   
      /**
       * Our XA session resource.
       */
      private XASession xaSession;
  -
  +   
      /**
       * The transaction manager that we will use for transactions.
       */
      private TransactionManager tm;
  -
  +   
      /**
       * Use the session's XAResource directly if we have an JBossMQ XASession.
       * this allows us to get around the TX timeout problem when you have
       * extensive message processing.
       */
      private boolean useLocalTX;
  -
  +   
      /**
       * The listener to delegate calls, to. In our case the container invoker.
       */
      private MessageListener delegateListener;
  -
  +   
      /**
       * Create a <tt>StdServerSession</tt> .
       *
  @@ -85,38 +85,37 @@
       * @exception JMSException  Description of Exception
       */
      StdServerSession(final StdServerSessionPool pool,
  -         final Session session,
  -         final XASession xaSession,
  -      final MessageListener delegateListener,
  -         boolean useLocalTX)
  -          throws JMSException
  +      final Session session,
  +      final XASession xaSession,
  +      final MessageListener delegateListener,
  +      boolean useLocalTX)
  +      throws JMSException
      {
         // assert pool != null
         // assert session != null
  -
  +      
         this.serverSessionPool = pool;
         this.session = session;
         this.xaSession = xaSession;
         this.delegateListener = delegateListener;
         if( xaSession == null )
  -           useLocalTX = false;
  +         useLocalTX = false;
         this.useLocalTX = useLocalTX;
  -
  +      
         log.debug("initializing (pool, session, xaSession, useLocalTX): " +
  -            pool + ", " + session + ", " + xaSession + ", " + useLocalTX);
  -
  +      pool + ", " + session + ", " + xaSession + ", " + useLocalTX);
  +      
         // Set out self as message listener
         if (xaSession != null)
  -              xaSession.setMessageListener(this);
  +         xaSession.setMessageListener(this);
         else
  -       session.setMessageListener(this);
  -
  +         session.setMessageListener(this);
  +      
         InitialContext ctx = null;
         try
         {
            ctx = new InitialContext();
  -         tm = (TransactionManager)
  -               ctx.lookup(TransactionManagerService.JNDI_NAME);
  +         tm = (TransactionManager) ctx.lookup(TransactionManagerService.JNDI_NAME);
         }
         catch (Exception e)
         {
  @@ -136,9 +135,9 @@
            }
         }
      }
  -
  +   
      // --- Impl of JMS standard API
  -
  +   
      /**
       * Returns the session. <p>
       *
  @@ -152,13 +151,13 @@
      public Session getSession() throws JMSException
      {
         if (xaSession != null)
  -              return xaSession;
  +         return xaSession;
         else
  -      return session;
  +         return session;
      }
  -
  +   
      //--- Protected parts, used by other in the package
  -
  +   
      /**
       * 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
  @@ -167,11 +166,12 @@
       */
      public void run()
      {
  -      log.debug("running...");
  +      if( log.isTraceEnabled() )
  +         log.trace("running...");
         if (xaSession != null)
  -              xaSession.run();
  +         xaSession.run();
         else
  -      session.run();
  +         session.run();
      }
      /**
       * Will get called from session for each message stuffed into it.
  @@ -185,20 +185,21 @@
       * leaving it this way since it keeps the code simpler and that case should
       * not be too common (JBossMQ provides XASessions).
       */
  -   public void onMessage(Message msg) {
  +   public void onMessage(Message msg)
  +   {      
  +      boolean trace = log.isTraceEnabled();
  +      if( trace )
  +         log.trace("onMessage running (pool, session, xaSession, useLocalTX): " +
  +         ", " + session + ", " + xaSession + ", " + useLocalTX);
   
  -      log.info("running (pool, session, xaSession, useLocalTX): " +
  -            ", " + session + ", " + xaSession + ", " + useLocalTX);
  -
         // Used if run with useLocalTX if true
         Xid localXid = null;
         boolean localRollbackFlag=false;
  -
         // Used if run with useLocalTX if false
         Transaction trans = null;
         try
         {
  -
  +         
            if (useLocalTX)
            {
               // Use JBossMQ One Phase Commit to commit the TX
  @@ -206,34 +207,35 @@
               XAResource res = xaSession.getXAResource();
               res.start(localXid, XAResource.TMNOFLAGS);
               
  -            if (log.isTraceEnabled()) log.trace("Using optimized 1p commit to 
control TX.");
  -
  +            if( trace )
  +               log.trace("Using optimized 1p commit to control TX.");
            }
            else
            {
  -
  +            
               // Use the TM to control the TX
               tm.begin();
               trans = tm.getTransaction();
  -
  +            
               if (xaSession != null)
               {
                  XAResource res = xaSession.getXAResource();
                  trans.enlistResource(res);
  -               if (log.isTraceEnabled()) log.trace("XAResource '" + res + "' 
enlisted.");
  +               if( trace )
  +                  log.trace("XAResource '" + res + "' enlisted.");
               }
            }
            //currentTransactionId = connection.spyXAResourceManager.startTx();
  -
  +         
            // run the session
            //session.run();
  -      // Call delegate listener
  -      delegateListener.onMessage(msg);
  +         // Call delegate listener
  +         delegateListener.onMessage(msg);
         }
         catch (Exception e)
         {
            log.error("session failed to run; setting rollback only", e);
  -
  +         
            if (useLocalTX)
            {
               // Use JBossMQ One Phase Commit to commit the TX
  @@ -241,12 +243,12 @@
            }
            else
            {
  -
               // Mark for tollback TX via TM
               try
               {
                  // The transaction will be rolledback in the finally
  -               if (log.isTraceEnabled()) log.trace("Using TM to mark TX for 
rollback.");
  +               if( trace )
  +                  log.trace("Using TM to mark TX for rollback.");
                  trans.setRollbackOnly();
               }
               catch (Exception x)
  @@ -254,7 +256,7 @@
                  log.error("failed to set rollback only", x);
               }
            }
  -
  +         
         }
         finally
         {
  @@ -262,33 +264,37 @@
            {
               if (useLocalTX)
               {
  -             if( localRollbackFlag == true  ) {
  -                         if (log.isTraceEnabled()) log.trace("Using optimized 1p 
commit to rollback TX.");
  -                         
  -                         XAResource res = xaSession.getXAResource();
  -                         res.end(localXid, XAResource.TMSUCCESS);
  -                         res.rollback(localXid);
  -                         
  -             } else {
  -                         if (log.isTraceEnabled()) log.trace("Using optimized 1p 
commit to commit TX.");
  -                         
  -                         XAResource res = xaSession.getXAResource();
  -                         res.end(localXid, XAResource.TMSUCCESS);
  -                         res.commit(localXid, true);
  -             }               
  -
  +               if( localRollbackFlag == true  )
  +               {
  +                  if( trace )
  +                     log.trace("Using optimized 1p commit to rollback TX.");
  +                  
  +                  XAResource res = xaSession.getXAResource();
  +                  res.end(localXid, XAResource.TMSUCCESS);
  +                  res.rollback(localXid);
  +                  
  +               }
  +               else
  +               {
  +                  if( trace )
  +                     log.trace("Using optimized 1p commit to commit TX.");
  +                  
  +                  XAResource res = xaSession.getXAResource();
  +                  res.end(localXid, XAResource.TMSUCCESS);
  +                  res.commit(localXid, true);
  +               }
               }
               else
               {
  -               // Use the TM to commit the Tx
  -
  +               // Use the TM to commit the Tx               
                  // Marked rollback
                  if (trans.getStatus() == Status.STATUS_MARKED_ROLLBACK)
                  {
  -                  log.debug("Rolling back JMS transaction");
  +                  if( trace )
  +                     log.trace("Rolling back JMS transaction");
                     // actually roll it back
                     trans.rollback();
  -
  +                  
                     // NO XASession? then manually rollback.
                     // This is not so good but
                     // it's the best we can do if we have no XASession.
  @@ -303,7 +309,8 @@
                     // This will happen if
                     // a) everything goes well
                     // b) app. exception was thrown
  -                  if (log.isTraceEnabled()) log.trace("Commiting the JMS 
transaction");
  +                  if( trace )
  +                     log.trace("Commiting the JMS transaction");
                     trans.commit();
   
                     // NO XASession? then manually commit.  This is not so good but
  @@ -313,17 +320,17 @@
                        session.commit();
                     }
                  }
  -            }
  -
  +            }            
            }
            catch (Exception e)
            {
               log.error("failed to commit/rollback", e);
            }
  -
  +         
            StdServerSession.this.recycle();
         }
  -      if (log.isTraceEnabled()) log.trace("done");
  +      if( trace )
  +         log.trace("onMessage done");
      }
   
      /**
  @@ -333,8 +340,9 @@
       */
      public void start() throws JMSException
      {
  -      log.debug("starting invokes on server session");
  -
  +      if( log.isTraceEnabled() )
  +         log.trace("starting invokes on server session");
  +      
         if (session != null)
         {
            try
  @@ -350,7 +358,7 @@
            throw new JMSException("No listener has been specified");
         }
      }
  -
  +   
      /**
       * Called by the ServerSessionPool when the sessions should be closed.
       */
  @@ -365,10 +373,10 @@
            catch (Exception ignore)
            {
            }
  -
  +         
            session = null;
         }
  -
  +      
         if (xaSession != null)
         {
            try
  @@ -380,10 +388,10 @@
            }
            xaSession = null;
         }
  -
  +      
         log.debug("closed");
      }
  -
  +   
      /**
       * This method is called by the ServerSessionPool when it is ready to be
       * recycled intot the pool
  @@ -392,8 +400,6 @@
      {
         serverSessionPool.recycle(this);
      }
  -
  -
  +   
   }
  -
   
  
  
  
  1.16      +11 -22    jboss/src/main/org/jboss/jms/asf/StdServerSessionPool.java
  
  Index: StdServerSessionPool.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/jms/asf/StdServerSessionPool.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- StdServerSessionPool.java 2001/12/12 22:12:18     1.15
  +++ StdServerSessionPool.java 2001/12/13 13:32:05     1.16
  @@ -28,7 +28,7 @@
   import javax.jms.XATopicConnection;
   import javax.jms.XATopicSession;
   
  -import org.apache.log4j.Category;
  +import org.jboss.logging.Logger;
   
   /**
    * Implementation of ServerSessionPool. <p>
  @@ -37,7 +37,7 @@
    *
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Peter Antman</a> .
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a> .
  - * @version   $Revision: 1.15 $
  + * @version   $Revision: 1.16 $
    */
   public class StdServerSessionPool
          implements ServerSessionPool
  @@ -56,7 +56,7 @@
      /**
       * Instance logger.
       */
  -   private final Category log = Category.getInstance(this.getClass());
  +   private final Logger log = Logger.getLogger(this.getClass());
   
      /**
       * The size of the pool.
  @@ -126,7 +126,7 @@
            final boolean useLocalTX,
            final MessageListener listener,
            final int maxSession)
  -          throws JMSException
  +         throws JMSException
      {
         this.con = con;
         this.ack = ack;
  @@ -175,7 +175,8 @@
       */
      public ServerSession getServerSession() throws JMSException
      {
  -      log.debug("getting a server session");
  +      if( log.isTraceEnabled() )
  +         log.trace("getting a server session");
         ServerSession session = null;
   
         try
  @@ -212,8 +213,8 @@
         }
   
         // assert session != null
  -
  -      log.debug("using server session: " + session);
  +      if( log.isTraceEnabled() )
  +         log.trace("using server session: " + session);
         return session;
      }
   
  @@ -314,7 +315,8 @@
            {
               sessionPool.add(session);
               sessionPool.notifyAll();
  -            log.debug("recycled server session: " + session);
  +            if( log.isTraceEnabled() )
  +               log.trace("recycled server session: " + session);
            }
         }
      }
  @@ -360,27 +362,14 @@
               throw new JMSException("Connection was not reconizable: " + con);
            }
   
  -
  -
            // create the server session and add it to the pool - it is up to the
  -      // server session to set the listener
  +         // server session to set the listener
            StdServerSession serverSession = new StdServerSession(this, ses, xaSes, 
listener, useLocalTX);
   
  -
  -         // This might not be totaly spec compliant since it says that app
  -         // server should create as many message listeners its needs.
  -         //log.debug("setting session listener: " + listener);
  -      //if(xaSession
  -      //ses.setMessageListener(serverSession);
  -      //FIXME, it seems as if Sonic is using ites XaSession to do all work
  -      //if (xaSes != null)
  -      //   xaSes.setMessageListener(serverSession);
  -
            sessionPool.add(serverSession);
            numServerSessions++;
            log.debug("added server session to the pool: " + serverSession);
         }
      }
   }
  -
   
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to