[jboss-svn-commits] JBL Code SVN: r11152 - in labs/jbossesb/trunk/product: core/listeners/src/org/jboss/soa/esb/listeners/message and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Apr 20 07:47:54 EDT 2007


Author: kevin.conner at jboss.com
Date: 2007-04-20 07:47:53 -0400 (Fri, 20 Apr 2007)
New Revision: 11152

Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/MessageAwareListener.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
   labs/jbossesb/trunk/product/samples/quickstarts/helloworld/log4j.xml
Log:
Moved error messages to debug and changes console logging to show INFO upwards: JBESB-312

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java	2007-04-20 11:35:38 UTC (rev 11151)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java	2007-04-20 11:47:53 UTC (rev 11152)
@@ -67,7 +67,6 @@
 
 public class JmsGatewayListener extends AbstractThreadedManagedLifecycle
 {
-
         /**
          * serial version uid for this class
          */
@@ -77,7 +76,6 @@
 	{
             super(listenerConfig) ;
             _config = listenerConfig;
-            _sleepForRetries = 3000; // milliseconds TODO magic number
             checkMyParms();
 	} // __________________________________
 
@@ -101,45 +99,33 @@
                 throw new ManagedLifecycleException("Unexpected registry exception", re) ;
             }
             
-            if (_serviceName != null)
-            {
-                try
-                {
-                    RegistryUtil.register(_config, _myEpr);
-                }
-                catch (final RegistryException re)
-                {
-                    throw new ManagedLifecycleException("Unexpected error during registration for epr " + _myEpr, re);
-                }
-            }
-            
             try
             {
                 prepareMessageReceiver();
             }
             catch (final ConnectionException ce)
             {
-                   if (_serviceName != null)
-                   {
-                      RegistryUtil.unregister(_serviceCategory, _serviceName, _myEpr);
-                   }
-                   throw new ManagedLifecycleException("Unexpected JMS error from prepareMessageReceiver", ce);
+               throw new ManagedLifecycleException("Unexpected connection exception from prepareMessageReceiver", ce);
             }
             catch (final JMSException jmse)
             {
-                if (_serviceName != null)
-                {
-                    RegistryUtil.unregister(_serviceCategory, _serviceName, _myEpr) ;
-                }
                 throw new ManagedLifecycleException("Unexpected JMS error from prepareMessageReceiver", jmse);
             }
             catch (final ConfigurationException ce)
             {
-                if (_serviceName != null)
+                throw new ManagedLifecycleException("Unexpected configuration exception from prepareMessageReceiver", ce);
+            }
+            
+            if (_serviceName != null)
+            {
+                try
                 {
-                    RegistryUtil.unregister(_serviceCategory, _serviceName, _myEpr) ;
+                    RegistryUtil.register(_config, _myEpr);
                 }
-                throw new ManagedLifecycleException("Unexpected configuration exception from prepareMessageReceiver", ce);
+                catch (final RegistryException re)
+                {
+                    throw new ManagedLifecycleException("Unexpected error during registration for epr " + _myEpr, re);
+                }
             }
         }
         
@@ -230,6 +216,11 @@
         protected void doDestroy()
             throws ManagedLifecycleException
         {
+            if (_serviceName != null)
+            {
+                RegistryUtil.unregister(_serviceCategory, _serviceName, _myEpr) ;
+            }
+            
             if (_messageReceiver != null)
             {
                 try
@@ -243,12 +234,6 @@
             {
                     _pool.closeSession(_queueSession);
             }
-            
-            if (_serviceName != null)
-            {
-                RegistryUtil.unregister(_serviceCategory, _serviceName, _myEpr) ;
-            }
-            
         }
 
 	/**
@@ -351,6 +336,11 @@
           
          try {
              _queueSession = _pool.getQueueSession();
+         } catch (NamingException ne) {
+             throw new ConfigurationException("Failed to obtain queue session from pool", ne) ;
+         }
+         
+         try {
              _queue = (Queue) oJndiCtx.lookup(_queueName);
          } catch (NamingException nex) {
              try {
@@ -389,16 +379,32 @@
 			}
 			catch (JMSException oJ)
 			{
-				_logger.error("JMS error on receive.  Attempting JMS Destination reconnect.",oJ);
+                                if (_logger.isDebugEnabled())
+                                {
+                                    _logger.debug("JMS error on receive.  Attempting JMS Destination reconnect.",oJ);
+                                }
 				try
 				{
 					prepareMessageReceiver();
+                                        errorDelay = 0 ;
 				}
 				// try to reconnect to the queue
 				catch (Exception e)
 				{
-					_logger.error("Reconnecting to Queue", e);
-                                        waitForRunningStateChange(ManagedLifecycleThreadState.STOPPING, _sleepForRetries) ;
+                                        if (_logger.isDebugEnabled())
+                                        {
+                                            _logger.debug("Reconnecting to Queue", e);
+                                        }
+                                        if (errorDelay == 0)
+                                        {
+                                            errorDelay = MIN_ERROR_DELAY ;
+                                        }
+                                        else if (errorDelay < MAX_ERROR_DELAY)
+                                        {
+                                            errorDelay <<= 1 ;
+                                        }
+                                        _logger.warn("Error reconnecting to Queue, backing off for " + errorDelay + " milliseconds") ;
+                                        waitForRunningStateChange(ManagedLifecycleThreadState.STOPPING, errorDelay) ;
 				}
 			}
 		return null;
@@ -482,8 +488,6 @@
 
 	protected ConfigTree _config;
 
-	protected final long _sleepForRetries; // milliseconds
-
 	protected String _serviceCategory, _serviceName;
 
 	protected String _targetServiceCategory, _targetServiceName;
@@ -503,4 +507,18 @@
 	protected Courier _courier;
     
     protected JmsConnectionPool _pool;
+    /**
+     * The minimum error delay.
+     */
+    private static final long MIN_ERROR_DELAY = 1000 ;
+    /**
+     * The maximum error delay.
+     */
+    private static final long MAX_ERROR_DELAY = (MIN_ERROR_DELAY << 5) ;
+    
+    /**
+     * The error delay.
+     */
+    private long errorDelay ;
+
 }

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/MessageAwareListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/MessageAwareListener.java	2007-04-20 11:35:38 UTC (rev 11151)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/MessageAwareListener.java	2007-04-20 11:47:53 UTC (rev 11152)
@@ -53,376 +53,370 @@
  * CourierFactory to obtain an appropriate Courier for the EPR this listener
  * will be listening on <br/>Keeps a thread pool to instantiate
  * ActionProcessingPipelines whenever a Message is received
- *
+ * 
  * @author <a
  *         href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
  * @since Version 4.0
  */
 
-public class MessageAwareListener extends AbstractThreadedManagedLifecycle
+public class MessageAwareListener  extends AbstractThreadedManagedLifecycle
 {
-   /**
-    * serial version uid for this class
-    */
-   private static final long serialVersionUID = -9198018611828254359L;
+        /**
+         * serial version uid for this class
+         */
+        private static final long serialVersionUID = -9198018611828254359L;
+        
+        /**
+         * The minimum error delay.
+         */
+        private static final long MIN_ERROR_DELAY = 1000 ;
+        /**
+         * The maximum error delay.
+         */
+        private static final long MAX_ERROR_DELAY = (MIN_ERROR_DELAY << 5) ;
+        
+        /**
+         * The action pipeline.
+         */
+        private ActionProcessingPipeline pipeline ;
+    
+        /**
+         * The error delay.
+         */
+        private long errorDelay ;
+        
+        /**
+	 * public constructor
+	 * 
+	 * @param config
+	 *            ConfigTree - Containing 'static' configuration for this
+	 *            instance
+	 * @throws ConfigurationException
+	 */
+	public MessageAwareListener(final ConfigTree config)
+			throws ConfigurationException
+	{
+            super(config);
+            _config = config ;
+            checkMyParms() ;
+	}
 
-   /**
-    * The minimum error delay.
-    */
-   private static final long MIN_ERROR_DELAY = 1000;
-   /**
-    * The maximum error delay.
-    */
-   private static final long MAX_ERROR_DELAY = (MIN_ERROR_DELAY << 5);
+	/**
+	 * Check for mandatory and optional attributes in parameter tree
+	 * 
+	 * @throws ConfigurationException -
+	 *             if mandatory atts are not right or actionClass not in
+	 *             classpath
+	 */
+	protected void checkMyParms () throws ConfigurationException
+	{
+                _eprCategoryName = _config.getAttribute(ListenerTagNames.SERVICE_CATEGORY_NAME_TAG);
+                _eprName = _config.getAttribute(ListenerTagNames.SERVICE_NAME_TAG);
 
-   /**
-    * The action pipeline.
-    */
-   private ActionProcessingPipeline pipeline;
+                final String maxThreadVal = _config.getAttribute(ListenerTagNames.MAX_THREADS_TAG) ;
+                
+                if (!Util.isNullString(maxThreadVal))
+                {
+                    try
+                    {
+                        _maxThreads = Integer.parseInt(maxThreadVal) ;
+                    }
+                    catch (NumberFormatException nfe)
+                    {
+                        _maxThreads = _defaultMaxThreads ;
+                        _logger.warn("Invalid " + ListenerTagNames.MAX_THREADS_TAG + " attribute, defaulting to <" + _maxThreads + ">") ;
+                    }
+                }
 
-   /**
-    * The error delay.
-    */
-   private long errorDelay;
+		if (Util.isNullString(_eprCategoryName))
+			throw new ConfigurationException(
+					"Missing or invalid " + ListenerTagNames.SERVICE_CATEGORY_NAME_TAG);
+		if (Util.isNullString(_eprName))
+			throw new ConfigurationException(
+					"Missing or invalid " + ListenerTagNames.SERVICE_NAME_TAG);
 
-   /**
-    * public constructor
-    *
-    * @param config ConfigTree - Containing 'static' configuration for this
-    *               instance
-    * @throws ConfigurationException
-    */
-   public MessageAwareListener(final ConfigTree config)
-           throws ConfigurationException
-   {
-      super(config);
-      _config = config;
-      checkMyParms();
-   }
-
-   /**
-    * Check for mandatory and optional attributes in parameter tree
-    *
-    * @throws ConfigurationException -
-    *                                if mandatory atts are not right or actionClass not in
-    *                                classpath
-    */
-   protected void checkMyParms() throws ConfigurationException
-   {
-      _eprCategoryName = _config.getAttribute(ListenerTagNames.SERVICE_CATEGORY_NAME_TAG);
-      _eprName = _config.getAttribute(ListenerTagNames.SERVICE_NAME_TAG);
-
-      final String maxThreadVal = _config.getAttribute(ListenerTagNames.MAX_THREADS_TAG);
-
-      if (!Util.isNullString(maxThreadVal))
-      {
-         try
-         {
-            _maxThreads = Integer.parseInt(maxThreadVal);
-         }
-         catch (NumberFormatException nfe)
-         {
-            _maxThreads = _defaultMaxThreads;
-            _logger.warn("Invalid " + ListenerTagNames.MAX_THREADS_TAG + " attribute, defaulting to <" + _maxThreads + ">");
-         }
-      }
-
-      if (Util.isNullString(_eprCategoryName))
-         throw new ConfigurationException(
-                 "Missing or invalid " + ListenerTagNames.SERVICE_CATEGORY_NAME_TAG);
-      if (Util.isNullString(_eprName))
-         throw new ConfigurationException(
-                 "Missing or invalid " + ListenerTagNames.SERVICE_NAME_TAG);
-
-      ConfigTree eprElement = _config.getFirstChild(ListenerTagNames.EPR_TAG);
-      if (null == eprElement)
-         throw new ConfigurationException(
-                 "Missing or invalid " + ListenerTagNames.EPR_TAG + " element");
-      _epr = ListenerUtil.assembleEpr(eprElement);
-
-      String latency = _config.getAttribute(ListenerTagNames.POLL_LATENCY_SECS_TAG);
-      long lSeconds = 10;
-      if (null != latency)
-      {
-         try
-         {
-            lSeconds = Integer.parseInt(latency);
-         }
-         catch (NumberFormatException e)
-         {
-            _logger.warn("Invalid number format <" + latency + "> using default value (" + lSeconds + ")");
-         }
-      }
-      _latencySecs = lSeconds;
-   }
-
-   /**
-    * Handle the initialisation of the managed instance.
-    *
-    * @throws ManagedLifecycleException for errors while initialisation.
-    */
-   protected void doInitialise()
-           throws ManagedLifecycleException
-   {
-      final ActionProcessingPipeline pipeline;
-      try
-      {
-         pipeline = new ActionProcessingPipeline(_config);
-         pipeline.initialise();
-      }
-      catch (final ConfigurationException ce)
-      {
-         throw new ManagedLifecycleException("Error configuring action processing pipeline", ce);
-      }
-      this.pipeline = pipeline;
-      final TwoWayCourier pickUpCourier;
-      try
-      {
-         pickUpCourier = CourierFactory.getPickupCourier(_epr);
-         try
-         {
-            final Method setPollLatency = pickUpCourier.getClass().getMethod(
-                    "setPollLatency", new Class[]{Long.class});
-            setPollLatency.invoke(pickUpCourier, new Long(1000 * _latencySecs));
-         }
-         catch (final NoSuchMethodException nsme)
-         {
-            // OK, just leave it null
-         }
-         catch (final Exception ex)
-         {
-            CourierUtil.cleanCourier(pickUpCourier);
-            throw new ManagedLifecycleException("Problems invoking setPollLatency(long)", ex);
-         }
-      }
-      catch (final MalformedEPRException mepre)
-      {
-         throw new ManagedLifecycleException("Malformed EPR: " + _epr);
-      }
-      catch (final CourierException ce)
-      {
-         throw new ManagedLifecycleException("No appropriate courier can be obtained for " + _epr, ce);
-      }
-
-      _pickUpCourier = pickUpCourier;
-
-      try
-      {
-         RegistryUtil.register(_config, _epr);
-      }
-      catch (final RegistryException re)
-      {
-         CourierUtil.cleanCourier(_pickUpCourier);
-         throw new ManagedLifecycleException("Unexpected error during registration for epr " + _epr, re);
-      }
-   }
-
-   /**
-    * Handle the start of the managed instance.
-    *
-    * @throws ManagedLifecycleException for errors while starting.
-    */
-   protected void doStart()
-           throws ManagedLifecycleException
-   {
-      checkExecutorTermination();
-
-      _execService = Executors.newFixedThreadPool(_maxThreads);
-
-      super.doStart();
-   }
-
-   /**
-    * Execute on the thread.
-    */
-   protected void doRun()
-   {
-      if (_logger.isDebugEnabled())
-      {
-         _logger.debug("doRun() method of " + this.getClass().getSimpleName()
-                 + " started on thread " + Thread.currentThread().getName());
-      }
-
-      while (isRunning())
-      {
-         // Only pickup a message when a thread is available
-         if (waitForThread(_pauseLapseInMillis))
-         {
-            waitForEventAndProcess(100);
-         }
-      }
-      if (null != _execService)
-         _execService.shutdown();
-
-      if (_logger.isDebugEnabled())
-      {
-         _logger.debug("run() method of " + this.getClass().getSimpleName()
-                 + " finished on thread " + Thread.currentThread().getName());
-      }
-   }
-
-   public void waitForEventAndProcess(long maxWaitMillis)
-   {
-      final Message message;
-      try
-      {
-         message = (maxWaitMillis > 0) ? _pickUpCourier
-                 .pickup(maxWaitMillis) : null;
-         errorDelay = 0;
-      }
-      catch (CourierTimeoutException e)
-      {
-         return;
-      }
-      catch (CourierException e)
-      {
-         _logger.error("Courier Exception", e);
-         if (errorDelay == 0)
-         {
-            errorDelay = MIN_ERROR_DELAY;
-         }
-         else if (errorDelay < MAX_ERROR_DELAY)
-         {
-            errorDelay <<= 1;
-         }
-         waitForRunningStateChange(ManagedLifecycleThreadState.STOPPING, errorDelay);
-         return;
-      }
-
-      if (null != message)
-      {
-         try
-         {
-            final Runnable pipelineRunner = new Runnable()
+		ConfigTree eprElement = _config.getFirstChild(ListenerTagNames.EPR_TAG);
+		if (null == eprElement)
+			throw new ConfigurationException(
+					"Missing or invalid " + ListenerTagNames.EPR_TAG + " element");
+		_epr = ListenerUtil.assembleEpr(eprElement);
+                
+                String latency = _config.getAttribute(ListenerTagNames.POLL_LATENCY_SECS_TAG);
+                long lSeconds = 10;
+                if (null != latency)
+                {
+                    try
+                    {
+                        lSeconds = Integer.parseInt(latency);
+                    }
+                    catch (NumberFormatException e)
+                    {
+                        _logger.warn("Invalid number format <" + latency + "> using default value (" + lSeconds + ")");
+                    }
+                }
+                _latencySecs = lSeconds ;                
+	}
+        
+        /**
+         * Handle the initialisation of the managed instance.
+         * 
+         * @throws ManagedLifecycleException for errors while initialisation.
+         */
+        protected void doInitialise()
+            throws ManagedLifecycleException
+        {
+            final ActionProcessingPipeline pipeline ;
+            try
             {
-               public void run()
-               {
-                  try
-                  {
-                     pipeline.process(message);
-                  }
-                  finally
-                  {
-                     updateThreadCount(-1);
-                  }
-               }
-            };
-            updateThreadCount(+1);
-            _execService.execute(pipelineRunner);
-         }
-         catch (Exception e)
-         {
-            _logger.error("ActionProcessingPipeline exception", e);
-            return;
-         }
-      }
-
-   } // ________________________________
-
-   /**
-    * Handle the destroy of the managed instance.
-    *
-    * @throws ManagedLifecycleException for errors while destroying.
-    */
-   protected void doDestroy()
-           throws ManagedLifecycleException
-   {
-      checkExecutorTermination();
-
-      pipeline.destroy();
-      pipeline = null;
-
-      CourierUtil.cleanCourier(_pickUpCourier);
-
-      RegistryUtil.unregister(_eprCategoryName, _eprName, _epr);
-   }
-
-   /**
-    * Check that the existing executor has been closed down.
-    *
-    * @throws ManagedLifecycleException If executor tasks are still active.
-    */
-   private void checkExecutorTermination()
-           throws ManagedLifecycleException
-   {
-      if (_execService != null)
-      {
-         try
-         {
+                pipeline = new ActionProcessingPipeline(_config) ;
+                pipeline.initialise() ;
+            }
+            catch (final ConfigurationException ce)
+            {
+                throw new ManagedLifecycleException("Error configuring action processing pipeline", ce) ;
+            }
+            this.pipeline = pipeline ;
+            final TwoWayCourier pickUpCourier ;
             try
             {
-               if (!_execService.awaitTermination(getTerminationPeriod(), TimeUnit.MILLISECONDS))
-               {
-                  throw new ManagedLifecycleException("Tasks remain active in executor");
-               }
+                pickUpCourier = CourierFactory.getPickupCourier(_epr) ;
+                try
+                {
+                    final Method setPollLatency = pickUpCourier.getClass().getMethod(
+                        "setPollLatency", new Class[] { Long.class });
+                    setPollLatency.invoke(pickUpCourier, new Long(1000 * _latencySecs));
+                }
+                catch (final NoSuchMethodException nsme)
+                {
+                        // OK, just leave it null
+                }
+                catch (final Exception ex)
+                {
+                    CourierUtil.cleanCourier(pickUpCourier);
+                    throw new ManagedLifecycleException("Problems invoking setPollLatency(long)", ex) ;
+                }
             }
-            catch (final InterruptedException ie)
+            catch (final MalformedEPRException mepre)
             {
-               throw new ManagedLifecycleException("Interrupted waiting for active tasks to terminate");
+                throw new ManagedLifecycleException("Malformed EPR: " + _epr) ;
             }
-         }
-         finally
-         {
-            _execService = null;
-         }
-      }
-   }
-
-   private boolean waitForThread(final long delay)
-   {
-      boolean result = true;
-      synchronized (_synchThreads)
-      {
-         if (_qRunningThreads >= _maxThreads)
-         {
+            catch (final CourierException ce)
+            {
+                throw new ManagedLifecycleException("No appropriate courier can be obtained for " + _epr, ce);
+            }
+            
+            _pickUpCourier = pickUpCourier ;
+         
             try
             {
-               _synchThreads.wait(delay);
+                RegistryUtil.register(_config, _epr);
             }
-            catch (final InterruptedException ie)
+            catch (final RegistryException re)
             {
+                CourierUtil.cleanCourier(_pickUpCourier);
+                throw new ManagedLifecycleException("Unexpected error during registration for epr " + _epr, re);
             }
-            result = _qRunningThreads < _maxThreads;
-         }
-      }
-      return result;
-   }
+        }
+        
+        /**
+         * Handle the start of the managed instance.
+         * 
+         * @throws ManagedLifecycleException for errors while starting.
+         */
+        protected void doStart()
+            throws ManagedLifecycleException
+        {
+            checkExecutorTermination() ;
+            
+            _execService = Executors.newFixedThreadPool(_maxThreads) ;
+            
+            super.doStart() ;
+        }
+        
+        /**
+         * Execute on the thread.
+         */
+        protected void doRun()
+        {
+            if (_logger.isDebugEnabled())
+            {
+                _logger.debug("doRun() method of " + this.getClass().getSimpleName()
+                            + " started on thread " + Thread.currentThread().getName());
+            }
+            
+            while (isRunning())
+            {
+                // Only pickup a message when a thread is available
+                if (waitForThread(_pauseLapseInMillis))
+                {
+                    waitForEventAndProcess(100) ;
+                }
+            }
+            if (null != _execService)
+                _execService.shutdown();
 
-   private void updateThreadCount(Integer i)
-   {
-      synchronized (_synchThreads)
-      {
-         _qRunningThreads += i.intValue();
-         if (_qRunningThreads < _maxThreads)
-         {
-            _synchThreads.notifyAll();
-         }
-      }
-   }
+            if (_logger.isDebugEnabled())
+            {
+                _logger.debug("run() method of " + this.getClass().getSimpleName()
+                            + " finished on thread " + Thread.currentThread().getName());
+            }
+        }
+        
+	public void waitForEventAndProcess (long maxWaitMillis)
+	{
+		final Message message ;
+		try
+		{
+			message = (maxWaitMillis > 0) ? _pickUpCourier
+					.pickup(maxWaitMillis) : null;
+                        errorDelay = 0 ;
+		}
+		catch (CourierTimeoutException e)
+		{
+			return;
+		}
+		catch (CourierException e)
+		{
+                        _logger.debug("Courier Exception", e);
+                        if (errorDelay == 0)
+                        {
+                            errorDelay = MIN_ERROR_DELAY ;
+                        }
+                        else if (errorDelay < MAX_ERROR_DELAY)
+                        {
+                            errorDelay <<= 1 ;
+                        }
+                        _logger.warn("Error processing courier, backing off for " + errorDelay + " milliseconds") ;
+                        waitForRunningStateChange(ManagedLifecycleThreadState.STOPPING, errorDelay) ;
+			return;
+		}
 
-   private ConfigTree _config;
+		if (null != message)
+		{
+			try
+			{
+                            final Runnable pipelineRunner = new Runnable() {
+                                public void run() {
+                                    try {
+                                        pipeline.process(message) ;
+                                    } finally {
+                                        updateThreadCount(-1) ;
+                                    }
+                                }
+                            } ;
+                            updateThreadCount(+1);
+                            _execService.execute(pipelineRunner);
+			}
+			catch (Exception e)
+			{
+				_logger.error("ActionProcessingPipeline exception", e);
+				return;
+			}
+		}
 
-   private String _eprCategoryName;
+	} // ________________________________
+        
+        /**
+         * Handle the destroy of the managed instance.
+         * 
+         * @throws ManagedLifecycleException for errors while destroying.
+         */
+        protected void doDestroy()
+            throws ManagedLifecycleException
+        {
+            checkExecutorTermination() ;
+            
+            pipeline.destroy() ;
+            pipeline = null ;
+            
+            CourierUtil.cleanCourier(_pickUpCourier);
+            
+            RegistryUtil.unregister(_eprCategoryName, _eprName, _epr) ;
+        }
+        
+        /**
+         * Check that the existing executor has been closed down.
+         * @throws ManagedLifecycleException If executor tasks are still active.
+         */
+        private void checkExecutorTermination()
+            throws ManagedLifecycleException
+        {
+            if (_execService != null)
+            {
+                try
+                {
+                    try
+                    {
+                        if (!_execService.awaitTermination(getTerminationPeriod(), TimeUnit.MILLISECONDS))
+                        {
+                            throw new ManagedLifecycleException("Tasks remain active in executor") ;
+                        }
+                    }
+                    catch (final InterruptedException ie)
+                    {
+                        throw new ManagedLifecycleException("Interrupted waiting for active tasks to terminate") ;
+                    }
+                }
+                finally
+                {
+                    _execService = null ;
+                }
+            }
+        }
 
-   private String _eprName;
+        private boolean waitForThread(final long delay)
+        {
+            boolean result = true ;
+            synchronized(_synchThreads)
+            {
+                if (_qRunningThreads >= _maxThreads)
+                {
+                    try
+                    {
+                        _synchThreads.wait(delay) ;
+                    }
+                    catch (final InterruptedException ie) {}
+                    result = _qRunningThreads < _maxThreads ;
+                }
+            }
+            return result ;
+        }
 
-   private EPR _epr;
+        private void updateThreadCount(Integer i)
+        {
+            synchronized (_synchThreads)
+            {
+                _qRunningThreads += i.intValue();
+                if (_qRunningThreads < _maxThreads)
+                {
+                    _synchThreads.notifyAll() ;
+                }
+            }
+        }
 
-   private int _maxThreads;
+        private ConfigTree _config;
 
-   private int _defaultMaxThreads = 1;
+        private String _eprCategoryName;
 
-   private long _latencySecs;
+        private String _eprName;
 
-   private long _pauseLapseInMillis = 50;
+        private EPR _epr;
 
-   private ExecutorService _execService;
+        private int _maxThreads;
 
-   private Object _synchThreads = new Short((short) -1);
+        private int _defaultMaxThreads = 1;
+        
+        private long _latencySecs;
+        
+        private long _pauseLapseInMillis = 50 ;
 
-   private int _qRunningThreads;
+        private ExecutorService _execService;
 
-   private Logger _logger = Logger.getLogger(MessageAwareListener.class);
+        private Object _synchThreads = new Short((short) -1);
+        
+        private int _qRunningThreads;
 
-   private PickUpOnlyCourier _pickUpCourier;
+        private Logger _logger = Logger.getLogger(MessageAwareListener.class);
+        
+        private PickUpOnlyCourier _pickUpCourier;
 }

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2007-04-20 11:35:38 UTC (rev 11151)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2007-04-20 11:47:53 UTC (rev 11152)
@@ -101,7 +101,7 @@
 		}
 		catch (JMSException e)
 		{
-			_logger.error(e.getMessage(), e);
+			_logger.debug(e.getMessage(), e);
 		}
 
 		if (null != _messageConsumer) try
@@ -110,7 +110,7 @@
 		}
 		catch (JMSException e)
 		{
-			_logger.error(e.getMessage(), e);
+			_logger.debug(e.getMessage(), e);
 		}
 
 		if (null != _jmsSession)
@@ -191,12 +191,13 @@
 
 	private void jmsConnectRetry (Exception exc)
 	{
-		_logger.error("JMS error.  Attempting JMS reconnect.", exc);
+                _logger.debug("JMS error.  Attempting JMS reconnect.", exc);
 		_jmsSession = null;
 		_messageProducer = null;
 		_messageConsumer = null;
 
-		for (int i1 = 0; i1 < 5; i1++)
+                final int maxRetry = 5 ; // TODO Magic number here!!!
+		for (int i1 = 0; i1 < maxRetry; i1++)
 		{
 			// try to reconnect to the queue
 			try
@@ -207,16 +208,22 @@
 			}
 			catch (Exception e)
 			{
-				_logger.error("Reconnecting to JMS", e);
-				try
-				{
-					Thread.sleep(_sleepForRetries);
-				}
-				catch (InterruptedException e1)
-				{ // Just return after logging
-					_logger.error("Unexpected thread interupt exception.", e);
-					break;
-				}
+                                if (i1 < maxRetry-1)
+                                {
+                                    try
+                                    {
+                                            Thread.sleep(_sleepForRetries);
+                                    }
+                                    catch (InterruptedException e1)
+                                    { // Just return after logging
+                                        _logger.debug("Unexpected thread interupt exception.", e);
+                                        break;
+                                    }
+                                }
+                                else
+                                {
+                                    _logger.debug("Failed to reconnect to JMS", e);
+                                }
 			}
 		}
 	} // ________________________________
@@ -278,13 +285,13 @@
         }
 		catch (JMSException ex)
 		{
-			_logger.error("Error from JMS system.", ex);
+			_logger.debug("Error from JMS system.", ex);
 			
 			throw new CourierException(ex);
 		}
 		catch (NamingException ex)
 		{
-			_logger.error("JMX lookup error.", ex);
+			_logger.debug("JMX lookup error.", ex);
 			
 			throw new CourierException(ex);
 		}
@@ -428,7 +435,7 @@
         }
 		catch (JMSException ex)
 		{
-			_logger.error("Error from JMS system.", ex);
+			_logger.debug("Error from JMS system.", ex);
 			
 			throw new CourierException(ex);
 		}

Modified: labs/jbossesb/trunk/product/samples/quickstarts/helloworld/log4j.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld/log4j.xml	2007-04-20 11:35:38 UTC (rev 11151)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld/log4j.xml	2007-04-20 11:47:53 UTC (rev 11152)
@@ -23,6 +23,7 @@
    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="Target" value="System.out"/>
+      <param name="Threshold" value="INFO"/>
 
       <layout class="org.apache.log4j.PatternLayout">
          <!-- The default pattern: Date Priority [Category] Message\n -->




More information about the jboss-svn-commits mailing list