[hornetq-commits] JBoss hornetq SVN: r9517 - in trunk: src/main/org/hornetq/ra and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Aug 9 10:57:46 EDT 2010
Author: jmesnil
Date: 2010-08-09 10:57:46 -0400 (Mon, 09 Aug 2010)
New Revision: 9517
Modified:
trunk/docs/user-manual/en/appserver-integration.xml
trunk/src/main/org/hornetq/ra/HornetQRAProperties.java
trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java
trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
trunk/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java
Log:
https://jira.jboss.org/browse/HORNETQ-474: Resource Adapter inbound connection setup
* add setupInterval / setupAttempts at the RA level (in addition to the activation spec level)
* setting setupAttempts to -1 means infinite reconnection
* updated documentation
Modified: trunk/docs/user-manual/en/appserver-integration.xml
===================================================================
--- trunk/docs/user-manual/en/appserver-integration.xml 2010-08-09 14:42:28 UTC (rev 9516)
+++ trunk/docs/user-manual/en/appserver-integration.xml 2010-08-09 14:57:46 UTC (rev 9517)
@@ -678,6 +678,18 @@
<entry>Integer</entry>
<entry>the size of the thread pool</entry>
</row>
+ <row>
+ <entry>SetupAttempts</entry>
+ <entry>Integer</entry>
+ <entry>Number of attempts to setup a JMS connection (default is 10, -1 means to attempt infinitely). It is possible
+ that the MDB is deployed before the JMS resources are available. In that case, the resource
+ adapter will try to setup several times until the resources are available. This applies only for inbound connections</entry>
+ </row>
+ <row>
+ <entry>SetupInterval</entry>
+ <entry>Long</entry>
+ <entry>Interval in milliseconds between consecutive attemps to setup a JMS connection (default is 2000m). This applies only for inbound connections</entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
@@ -821,18 +833,6 @@
<entry>Boolean</entry>
<entry>Whether or not use JNDI to look up the destination (default is true)</entry>
</row>
- <row>
- <entry>SetupAttempts</entry>
- <entry>Integer</entry>
- <entry>Number of attemps to setup a JMS connection (default is 10). It is possible
- that the MDB is deployed before the JMS resources are available. In that case, the resource
- adapter will try to setup several times until the resources are available</entry>
- </row>
- <row>
- <entry>SetupInterval</entry>
- <entry>Long</entry>
- <entry>Interval in seconds between consecutive attemps to setup a JMS connection (default is 2 seconds)</entry>
- </row>
</tbody>
</tgroup>
</table>
Modified: trunk/src/main/org/hornetq/ra/HornetQRAProperties.java
===================================================================
--- trunk/src/main/org/hornetq/ra/HornetQRAProperties.java 2010-08-09 14:42:28 UTC (rev 9516)
+++ trunk/src/main/org/hornetq/ra/HornetQRAProperties.java 2010-08-09 14:57:46 UTC (rev 9517)
@@ -52,6 +52,14 @@
/** Method used to locate the TM */
private String transactionManagerLocatorMethod = "getTm;getTM";
+ private static final int DEFAULT_SETUP_ATTEMPTS = 10;
+
+ private static final long DEFAULT_SETUP_INTERVAL = 2 * 1000;
+
+ private int setupAttempts = DEFAULT_SETUP_ATTEMPTS;
+
+ private long setupInterval = DEFAULT_SETUP_INTERVAL;
+
/**
* Constructor
*/
@@ -168,7 +176,25 @@
this.transactionManagerLocatorMethod = transactionManagerLocatorMethod;
}
+ public int getSetupAttempts()
+ {
+ return setupAttempts;
+ }
+ public void setSetupAttempts(int setupAttempts)
+ {
+ this.setupAttempts = setupAttempts;
+ }
+
+ public long getSetupInterval()
+ {
+ return setupInterval;
+ }
+
+ public void setSetupInterval(long setupInterval)
+ {
+ this.setupInterval = setupInterval;
+ }
@Override
public String toString()
Modified: trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java
===================================================================
--- trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2010-08-09 14:42:28 UTC (rev 9516)
+++ trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2010-08-09 14:57:46 UTC (rev 9517)
@@ -1166,7 +1166,42 @@
raProperties.setUseLocalTx(localTx);
}
+ public int getSetupAttempts()
+ {
+ if (HornetQResourceAdapter.trace)
+ {
+ HornetQResourceAdapter.log.trace("getSetupAttempts()");
+ }
+ return raProperties.getSetupAttempts();
+ }
+ public void setSetupAttempts(int setupAttempts)
+ {
+ if (HornetQResourceAdapter.trace)
+ {
+ HornetQResourceAdapter.log.trace("setSetupAttempts(" + setupAttempts + ")");
+ }
+ raProperties.setSetupAttempts(setupAttempts);
+ }
+
+ public long getSetupInterval()
+ {
+ if (HornetQResourceAdapter.trace)
+ {
+ HornetQResourceAdapter.log.trace("getSetupInterval()");
+ }
+ return raProperties.getSetupInterval();
+ }
+
+ public void setSetupInterval(long interval)
+ {
+ if (HornetQResourceAdapter.trace)
+ {
+ HornetQResourceAdapter.log.trace("setSetupInterval(" + interval + ")");
+ }
+ raProperties.setSetupInterval(interval);
+ }
+
/**
* Indicates whether some other object is "equal to" this one.
*
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2010-08-09 14:42:28 UTC (rev 9516)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2010-08-09 14:57:46 UTC (rev 9517)
@@ -511,18 +511,21 @@
log.warn("Failure in HornetQ activation " + spec, failure);
}
int reconnectCount = 0;
+ int setupAttempts = spec.getSetupAttempts();
+ long setupInterval = spec.getSetupInterval();
+
// Only enter the failure loop once
if (inFailure.getAndSet(true))
return;
try
{
- while (deliveryActive.get() && reconnectCount < spec.getSetupAttempts())
+ while (deliveryActive.get() && (setupAttempts == -1 || reconnectCount < setupAttempts))
{
teardown();
try
{
- Thread.sleep(spec.getSetupInterval());
+ Thread.sleep(setupInterval);
}
catch (InterruptedException e)
{
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java 2010-08-09 14:42:28 UTC (rev 9516)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java 2010-08-09 14:57:46 UTC (rev 9517)
@@ -40,10 +40,6 @@
{
private static final int DEFAULT_MAX_SESSION = 15;
- private static final int DEFAULT_SETUP_ATTEMPTS = 10;
-
- private static final long DEFAULT_SETUP_INTERVAL = 2 * 1000;
-
/** The logger */
private static final Logger log = Logger.getLogger(HornetQActivationSpec.class);
@@ -93,10 +89,12 @@
/* use local tx instead of XA*/
private Boolean localTx;
- private int setupAttempts;
+ // undefined by default, default is specified at the RA level in HornetQRAProperties
+ private Integer setupAttempts;
+
+ // undefined by default, default is specified at the RA level in HornetQRAProperties
+ private Long setupInterval;
- private long setupInterval;
-
/**
* Constructor
*/
@@ -118,8 +116,6 @@
password = null;
maxSession = DEFAULT_MAX_SESSION;
transactionTimeout = 0;
- setupAttempts = DEFAULT_SETUP_ATTEMPTS;
- setupInterval = DEFAULT_SETUP_INTERVAL;
}
/**
@@ -542,21 +538,55 @@
public int getSetupAttempts()
{
- return setupAttempts;
+ if (HornetQActivationSpec.trace)
+ {
+ HornetQActivationSpec.log.trace("getSetupAttempts()");
+ }
+
+ if (setupAttempts == null)
+ {
+ return ra.getSetupAttempts();
+ }
+ else
+ {
+ return setupAttempts;
+ }
}
public void setSetupAttempts(int setupAttempts)
{
+ if (HornetQActivationSpec.trace)
+ {
+ HornetQActivationSpec.log.trace("setSetupAttempts(" + setupAttempts + ")");
+ }
+
this.setupAttempts = setupAttempts;
}
public long getSetupInterval()
{
- return setupInterval;
+ if (HornetQActivationSpec.trace)
+ {
+ HornetQActivationSpec.log.trace("getSetupInterval()");
+ }
+
+ if (setupInterval == null)
+ {
+ return ra.getSetupInterval();
+ }
+ else
+ {
+ return setupInterval;
+ }
}
public void setSetupInterval(long setupInterval)
{
+ if (HornetQActivationSpec.trace)
+ {
+ HornetQActivationSpec.log.trace("setSetupInterval(" + setupInterval + ")");
+ }
+
this.setupInterval = setupInterval;
}
More information about the hornetq-commits
mailing list