[jboss-cvs] JBossAS SVN: r64903 - trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 28 04:56:37 EDT 2007
Author: adrian at jboss.org
Date: 2007-08-28 04:56:37 -0400 (Tue, 28 Aug 2007)
New Revision: 64903
Modified:
trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java
Log:
[JBAS-4640] - Avoid multiple threads in the reconnect
Modified: trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java 2007-08-28 08:54:29 UTC (rev 64902)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java 2007-08-28 08:56:37 UTC (rev 64903)
@@ -78,7 +78,10 @@
/** Whether delivery is active */
protected SynchronizedBoolean deliveryActive;
-
+
+ // Whether we are in the failure recovery loop
+ private SynchronizedBoolean inFailure = new SynchronizedBoolean(false);
+
/** The jms provider adapter */
protected JMSProviderAdapter adapter;
@@ -231,34 +234,43 @@
log.warn("Failure in jms activation " + spec, failure);
int reconnectCount = 0;
- while (deliveryActive.get() && reconnectCount < spec.getReconnectAttempts())
+ // Only enter the failure loop once
+ if (inFailure.set(true))
+ return;
+ try
{
- teardown();
- try
+ while (deliveryActive.get() && reconnectCount < spec.getReconnectAttempts())
{
- Thread.sleep(spec.getReconnectIntervalLong());
- }
- catch (InterruptedException e)
- {
- log.debug("Interrupted trying to reconnect " + spec, e);
- break;
- }
+ teardown();
+ try
+ {
+ Thread.sleep(spec.getReconnectIntervalLong());
+ }
+ catch (InterruptedException e)
+ {
+ log.debug("Interrupted trying to reconnect " + spec, e);
+ break;
+ }
- log.info("Attempting to reconnect " + spec);
- try
- {
- setup();
- log.info("Reconnected with messaging provider.");
- break;
+ log.info("Attempting to reconnect " + spec);
+ try
+ {
+ setup();
+ log.info("Reconnected with messaging provider.");
+ break;
+ }
+ catch (Throwable t)
+ {
+ log.error("Unable to reconnect " + spec, t);
+ }
+ ++reconnectCount;
}
- catch (Throwable t)
- {
- log.error("Unable to reconnect " + spec, t);
- }
-
- ++reconnectCount;
-
}
+ finally
+ {
+ // Leaving failure recovery loop
+ inFailure.set(false);
+ }
}
public void onException(JMSException exception)
@@ -403,6 +415,7 @@
*/
protected void teardownDestination()
{
+ destination = null;
}
/**
@@ -607,6 +620,7 @@
{
log.debug("Error clearing the pool " + pool, t);
}
+ pool = null;
}
/**
More information about the jboss-cvs-commits
mailing list