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
|
@ -56,24 +56,26 @@ public class NetworkFailoverTest extends TestCase {
|
||||||
protected BrokerService remoteBroker;
|
protected BrokerService remoteBroker;
|
||||||
protected Session localSession;
|
protected Session localSession;
|
||||||
protected Session remoteSession;
|
protected Session remoteSession;
|
||||||
protected ActiveMQQueue included=new ActiveMQQueue("include.test.foo");
|
protected ActiveMQQueue included = new ActiveMQQueue("include.test.foo");
|
||||||
protected String consumerName = "durableSubs";
|
protected String consumerName = "durableSubs";
|
||||||
|
|
||||||
public void testRequestReply() throws Exception {
|
public void testRequestReply() throws Exception {
|
||||||
final MessageProducer remoteProducer = remoteSession.createProducer(null);
|
final MessageProducer remoteProducer = remoteSession.createProducer(null);
|
||||||
MessageConsumer remoteConsumer = remoteSession.createConsumer(included);
|
MessageConsumer remoteConsumer = remoteSession.createConsumer(included);
|
||||||
remoteConsumer.setMessageListener(new MessageListener() {
|
remoteConsumer.setMessageListener(new MessageListener() {
|
||||||
|
@Override
|
||||||
public void onMessage(Message msg) {
|
public void onMessage(Message msg) {
|
||||||
try {
|
try {
|
||||||
TextMessage textMsg = (TextMessage)msg;
|
TextMessage textMsg = (TextMessage) msg;
|
||||||
String payload = "REPLY: " + textMsg.getText();
|
String payload = "REPLY: " + textMsg.getText();
|
||||||
Destination replyTo;
|
Destination replyTo;
|
||||||
replyTo = msg.getJMSReplyTo();
|
replyTo = msg.getJMSReplyTo();
|
||||||
textMsg.clearBody();
|
textMsg.clearBody();
|
||||||
textMsg.setText(payload);
|
textMsg.setText(payload);
|
||||||
|
LOG.info("*** Sending response: {}", textMsg.getText());
|
||||||
remoteProducer.send(replyTo, textMsg);
|
remoteProducer.send(replyTo, textMsg);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
LOG.warn("*** Responder listener caught exception: ", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,35 +93,39 @@ public class NetworkFailoverTest extends TestCase {
|
||||||
TextMessage msg = localSession.createTextMessage(payload);
|
TextMessage msg = localSession.createTextMessage(payload);
|
||||||
msg.setJMSReplyTo(tempQueue);
|
msg.setJMSReplyTo(tempQueue);
|
||||||
requestProducer.send(msg);
|
requestProducer.send(msg);
|
||||||
LOG.info("Failing over");
|
LOG.info("*** Failing over for iteration: #{}", i);
|
||||||
((FailoverTransport) ((TransportFilter) ((TransportFilter)
|
((FailoverTransport) ((TransportFilter) ((TransportFilter) ((ActiveMQConnection) localConnection).getTransport()).getNext()).getNext())
|
||||||
((ActiveMQConnection) localConnection)
|
|
||||||
.getTransport()).getNext()).getNext())
|
|
||||||
.handleTransportFailure(new IOException("Forcing failover from test"));
|
.handleTransportFailure(new IOException("Forcing failover from test"));
|
||||||
TextMessage result = (TextMessage)requestConsumer.receive(10000);
|
TextMessage result = (TextMessage) requestConsumer.receive(10000);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
|
LOG.info("*** Iteration #{} got response: {}", i, result.getText());
|
||||||
LOG.info(result.getText());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
doSetUp(true);
|
doSetUp(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
doTearDown();
|
doTearDown();
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doTearDown() throws Exception {
|
protected void doTearDown() throws Exception {
|
||||||
|
try {
|
||||||
localConnection.close();
|
localConnection.close();
|
||||||
remoteConnection.close();
|
remoteConnection.close();
|
||||||
|
} catch(Exception ex) {}
|
||||||
|
|
||||||
|
try {
|
||||||
localBroker.stop();
|
localBroker.stop();
|
||||||
|
} catch(Exception ex) {}
|
||||||
|
try {
|
||||||
remoteBroker.stop();
|
remoteBroker.stop();
|
||||||
|
} catch(Exception ex) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doSetUp(boolean deleteAllMessages) throws Exception {
|
protected void doSetUp(boolean deleteAllMessages) throws Exception {
|
||||||
|
@ -127,17 +133,20 @@ public class NetworkFailoverTest extends TestCase {
|
||||||
remoteBroker = createRemoteBroker();
|
remoteBroker = createRemoteBroker();
|
||||||
remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
|
remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
|
||||||
remoteBroker.start();
|
remoteBroker.start();
|
||||||
|
|
||||||
localBroker = createLocalBroker();
|
localBroker = createLocalBroker();
|
||||||
localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
|
localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
|
||||||
localBroker.start();
|
localBroker.start();
|
||||||
|
|
||||||
String localURI = "tcp://localhost:61616";
|
String localURI = "tcp://localhost:61616";
|
||||||
String remoteURI = "tcp://localhost:61617";
|
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
|
||||||
//ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI);
|
+ ")?randomize=false&backup=true&trackMessages=true");
|
||||||
|
// ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI);
|
||||||
localConnection = fac.createConnection();
|
localConnection = fac.createConnection();
|
||||||
localConnection.setClientID("local");
|
localConnection.setClientID("local");
|
||||||
localConnection.start();
|
localConnection.start();
|
||||||
fac = new ActiveMQConnectionFactory("failover:("+remoteURI + ","+localURI+")?randomize=false&backup=true&trackMessages=true");
|
fac = new ActiveMQConnectionFactory("failover:(" + remoteURI + "," + localURI + ")?randomize=false&backup=true&trackMessages=true");
|
||||||
fac.setWatchTopicAdvisories(false);
|
fac.setWatchTopicAdvisories(false);
|
||||||
remoteConnection = fac.createConnection();
|
remoteConnection = fac.createConnection();
|
||||||
remoteConnection.setClientID("remote");
|
remoteConnection.setClientID("remote");
|
||||||
|
|
Loading…
Reference in New Issue