git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@587216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2007-10-22 19:37:01 +00:00
parent 6bb7fba3c5
commit d3d58fe41d
2 changed files with 44 additions and 0 deletions

View File

@ -253,6 +253,8 @@ public class FailoverTransport implements CompositeTransport {
started = true;
if (connectedTransport != null) {
stateTracker.restore(connectedTransport);
} else {
reconnect();
}
}
}

View File

@ -0,0 +1,42 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.transport.discovery;
import javax.jms.Connection;
import javax.jms.JMSException;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.CombinationTestSupport;
public class DiscoveryTransportNoBrokerTest extends CombinationTestSupport {
public void testMaxReconnectAttempts() throws JMSException {
long start = System.currentTimeMillis();
try {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://doesNOTexist)?maxReconnectAttempts=1");
System.out.println("Connecting.");
Connection connection = factory.createConnection();
connection.setClientID("test");
fail("Did not fail to connect as expected.");
} catch ( JMSException expected ) {
long duration = System.currentTimeMillis() - start;
// Should have failed fairly quickly since we are only giving it 1 reconnect attempt.
assertTrue(duration < 1000*5 );
}
}
}