Author: ataylor
Date: 2011-06-27 11:31:15 -0400 (Mon, 27 Jun 2011)
New Revision: 10888
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
Log:
added reconnect logic to serverlocator
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-06-27
14:20:38 UTC (rev 10887)
+++
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-06-27
15:31:15 UTC (rev 10888)
@@ -588,6 +588,7 @@
{
boolean retry;
int attempts = 0;
+ int cfAttempts = 0;
do
{
retry = false;
@@ -610,7 +611,7 @@
threadPool,
scheduledThreadPool,
interceptors);
- factory.connect(reconnectAttempts, failoverOnInitialConnection);
+ factory.connect(1, failoverOnInitialConnection);
}
catch (HornetQException e)
{
@@ -618,15 +619,21 @@
factory = null;
if (e.getCode() == HornetQException.NOT_CONNECTED)
{
- attempts++;
-
- if (topologyArray != null && attempts == topologyArray.length)
+ cfAttempts ++;
+ if (topologyArray != null && cfAttempts ==
topologyArray.length)
{
- throw new HornetQException(HornetQException.NOT_CONNECTED,
- "Cannot connect to server(s). Tried
with all available servers.");
+ attempts++;
+ cfAttempts = 0;
+ wait(retryInterval);
}
- if (topologyArray == null && initialConnectors != null
&& attempts == initialConnectors.length)
+ if (topologyArray == null && initialConnectors != null
&& cfAttempts == initialConnectors.length)
{
+ attempts++;
+ cfAttempts = 0;
+ wait(retryInterval);
+ }
+ if (initialConnectAttempts != -1 && attempts >=
initialConnectAttempts)
+ {
throw new HornetQException(HornetQException.NOT_CONNECTED,
"Cannot connect to server(s). Tried
with all available servers.");
}
Show replies by date