mirror of https://github.com/apache/activemq.git
Added in some more useful logging and cleaned up the stop code.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1440733 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d2c901f0ca
commit
0f3fdd7aa7
|
@ -63,6 +63,7 @@ public class NetworkFailoverTest extends TestCase {
|
|||
final MessageProducer remoteProducer = remoteSession.createProducer(null);
|
||||
MessageConsumer remoteConsumer = remoteSession.createConsumer(included);
|
||||
remoteConsumer.setMessageListener(new MessageListener() {
|
||||
@Override
|
||||
public void onMessage(Message msg) {
|
||||
try {
|
||||
TextMessage textMsg = (TextMessage) msg;
|
||||
|
@ -71,9 +72,10 @@ public class NetworkFailoverTest extends TestCase {
|
|||
replyTo = msg.getJMSReplyTo();
|
||||
textMsg.clearBody();
|
||||
textMsg.setText(payload);
|
||||
LOG.info("*** Sending response: {}", textMsg.getText());
|
||||
remoteProducer.send(replyTo, textMsg);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.warn("*** Responder listener caught exception: ", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -91,35 +93,39 @@ public class NetworkFailoverTest extends TestCase {
|
|||
TextMessage msg = localSession.createTextMessage(payload);
|
||||
msg.setJMSReplyTo(tempQueue);
|
||||
requestProducer.send(msg);
|
||||
LOG.info("Failing over");
|
||||
((FailoverTransport) ((TransportFilter) ((TransportFilter)
|
||||
((ActiveMQConnection) localConnection)
|
||||
.getTransport()).getNext()).getNext())
|
||||
LOG.info("*** Failing over for iteration: #{}", i);
|
||||
((FailoverTransport) ((TransportFilter) ((TransportFilter) ((ActiveMQConnection) localConnection).getTransport()).getNext()).getNext())
|
||||
.handleTransportFailure(new IOException("Forcing failover from test"));
|
||||
TextMessage result = (TextMessage) requestConsumer.receive(10000);
|
||||
assertNotNull(result);
|
||||
|
||||
LOG.info(result.getText());
|
||||
LOG.info("*** Iteration #{} got response: {}", i, result.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
doSetUp(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
doTearDown();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected void doTearDown() throws Exception {
|
||||
try {
|
||||
localConnection.close();
|
||||
remoteConnection.close();
|
||||
} catch(Exception ex) {}
|
||||
|
||||
try {
|
||||
localBroker.stop();
|
||||
} catch(Exception ex) {}
|
||||
try {
|
||||
remoteBroker.stop();
|
||||
} catch(Exception ex) {}
|
||||
}
|
||||
|
||||
protected void doSetUp(boolean deleteAllMessages) throws Exception {
|
||||
|
@ -127,12 +133,15 @@ public class NetworkFailoverTest extends TestCase {
|
|||
remoteBroker = createRemoteBroker();
|
||||
remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
|
||||
remoteBroker.start();
|
||||
|
||||
localBroker = createLocalBroker();
|
||||
localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
|
||||
localBroker.start();
|
||||
|
||||
String localURI = "tcp://localhost:61616";
|
||||
String remoteURI = "tcp://localhost:61617";
|
||||
ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory("failover:("+localURI+","+remoteURI+")?randomize=false&backup=true&trackMessages=true");
|
||||
ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory("failover:(" + localURI + "," + remoteURI
|
||||
+ ")?randomize=false&backup=true&trackMessages=true");
|
||||
// ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI);
|
||||
localConnection = fac.createConnection();
|
||||
localConnection.setClientID("local");
|
||||
|
|
Loading…
Reference in New Issue