resolve persistent hudson failure of org.apache.activemq.network.SimpleNetworkTest.testConduitBridge - individual cases were interfering with each other. A secondary failure, org.apache.activemq.network.SimpleNetworkTest#testDurableStoreAndForwardReconnect shows a problem with consuming an existing sub across a network, it won't work. It is not trivial to fix either, so virtual topics are a better bet in a network environment atm

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1304559 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2012-03-23 18:53:18 +00:00
parent d92d3a8a06
commit c3e57ec9fd
8 changed files with 60 additions and 36 deletions

View File

@ -19,6 +19,10 @@ package org.apache.activemq.network;
import javax.jms.MessageProducer; import javax.jms.MessageProducer;
import javax.jms.TemporaryQueue; import javax.jms.TemporaryQueue;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
public class DuplexNetworkTest extends SimpleNetworkTest { public class DuplexNetworkTest extends SimpleNetworkTest {
@ -34,7 +38,8 @@ public class DuplexNetworkTest extends SimpleNetworkTest {
broker.addConnector("tcp://localhost:61617"); broker.addConnector("tcp://localhost:61617");
return broker; return broker;
} }
@Test
public void testTempQueues() throws Exception { public void testTempQueues() throws Exception {
TemporaryQueue temp = localSession.createTemporaryQueue(); TemporaryQueue temp = localSession.createTemporaryQueue();
MessageProducer producer = localSession.createProducer(temp); MessageProducer producer = localSession.createProducer(temp);

View File

@ -95,8 +95,8 @@ public class NetworkFailoverTest extends TestCase {
((FailoverTransport) ((TransportFilter) ((TransportFilter) ((FailoverTransport) ((TransportFilter) ((TransportFilter)
((ActiveMQConnection) localConnection) ((ActiveMQConnection) localConnection)
.getTransport()).getNext()).getNext()) .getTransport()).getNext()).getNext())
.handleTransportFailure(new IOException()); .handleTransportFailure(new IOException("Forcing failover from test"));
TextMessage result = (TextMessage)requestConsumer.receive(); TextMessage result = (TextMessage)requestConsumer.receive(10000);
assertNotNull(result); assertNotNull(result);
LOG.info(result.getText()); LOG.info(result.getText());
@ -107,12 +107,10 @@ public class NetworkFailoverTest extends TestCase {
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
doSetUp(); doSetUp(true);
} }
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
localBroker.deleteAllMessages();
remoteBroker.deleteAllMessages();
doTearDown(); doTearDown();
super.tearDown(); super.tearDown();
} }
@ -124,20 +122,22 @@ public class NetworkFailoverTest extends TestCase {
remoteBroker.stop(); remoteBroker.stop();
} }
protected void doSetUp() throws Exception { protected void doSetUp(boolean deleteAllMessages) throws Exception {
remoteBroker = createRemoteBroker(); remoteBroker = createRemoteBroker();
remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
remoteBroker.start(); remoteBroker.start();
localBroker = createLocalBroker(); localBroker = createLocalBroker();
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+"?trackMessages=true)?randomize=false&backup=true"); ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory("failover:("+localURI+","+remoteURI+")?randomize=false&backup=true&trackMessages=true");
//ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI); //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"); 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");

View File

@ -23,6 +23,11 @@ import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.command.ConsumerId; import org.apache.activemq.command.ConsumerId;
import org.apache.activemq.util.Wait; import org.apache.activemq.util.Wait;
import org.apache.activemq.xbean.BrokerFactoryBean; import org.apache.activemq.xbean.BrokerFactoryBean;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.AbstractApplicationContext;
@ -34,7 +39,12 @@ import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class SimpleNetworkTest extends org.apache.activemq.TestSupport {
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
public class SimpleNetworkTest {
protected static final int MESSAGE_COUNT = 10; protected static final int MESSAGE_COUNT = 10;
private static final Logger LOG = LoggerFactory.getLogger(SimpleNetworkTest.class); private static final Logger LOG = LoggerFactory.getLogger(SimpleNetworkTest.class);
@ -50,6 +60,7 @@ public class SimpleNetworkTest extends org.apache.activemq.TestSupport {
protected ActiveMQTopic excluded; protected ActiveMQTopic excluded;
protected String consumerName = "durableSubs"; protected String consumerName = "durableSubs";
@Test
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);
@ -80,6 +91,7 @@ public class SimpleNetworkTest extends org.apache.activemq.TestSupport {
} }
} }
@Test
public void testFiltering() throws Exception { public void testFiltering() throws Exception {
MessageConsumer includedConsumer = remoteSession.createConsumer(included); MessageConsumer includedConsumer = remoteSession.createConsumer(included);
MessageConsumer excludedConsumer = remoteSession.createConsumer(excluded); MessageConsumer excludedConsumer = remoteSession.createConsumer(excluded);
@ -94,6 +106,7 @@ public class SimpleNetworkTest extends org.apache.activemq.TestSupport {
assertNotNull(includedConsumer.receive(1000)); assertNotNull(includedConsumer.receive(1000));
} }
@Test
public void testConduitBridge() throws Exception { public void testConduitBridge() throws Exception {
MessageConsumer consumer1 = remoteSession.createConsumer(included); MessageConsumer consumer1 = remoteSession.createConsumer(included);
MessageConsumer consumer2 = remoteSession.createConsumer(included); MessageConsumer consumer2 = remoteSession.createConsumer(included);
@ -137,13 +150,14 @@ public class SimpleNetworkTest extends org.apache.activemq.TestSupport {
})); }));
} }
@Test
public void testDurableStoreAndForward() throws Exception { public void testDurableStoreAndForward() throws Exception {
// create a remote durable consumer // create a remote durable consumer
MessageConsumer remoteConsumer = remoteSession.createDurableSubscriber(included, consumerName); MessageConsumer remoteConsumer = remoteSession.createDurableSubscriber(included, consumerName);
Thread.sleep(1000); Thread.sleep(1000);
// now close everything down and restart // now close everything down and restart
doTearDown(); doTearDown();
doSetUp(); doSetUp(false);
MessageProducer producer = localSession.createProducer(included); MessageProducer producer = localSession.createProducer(included);
for (int i = 0; i < MESSAGE_COUNT; i++) { for (int i = 0; i < MESSAGE_COUNT; i++) {
Message test = localSession.createTextMessage("test-" + i); Message test = localSession.createTextMessage("test-" + i);
@ -152,56 +166,59 @@ public class SimpleNetworkTest extends org.apache.activemq.TestSupport {
Thread.sleep(1000); Thread.sleep(1000);
// close everything down and restart // close everything down and restart
doTearDown(); doTearDown();
doSetUp(); doSetUp(false);
remoteConsumer = remoteSession.createDurableSubscriber(included, consumerName); remoteConsumer = remoteSession.createDurableSubscriber(included, consumerName);
for (int i = 0; i < MESSAGE_COUNT; i++) { for (int i = 0; i < MESSAGE_COUNT; i++) {
assertNotNull("message count: " + i, remoteConsumer.receive(2500)); assertNotNull("message count: " + i, remoteConsumer.receive(2500));
} }
} }
@Ignore("This seems like a simple use case, but it is problematic to consume an existing topic store, " +
"it requires a connection per durable to match that connectionId")
public void testDurableStoreAndForwardReconnect() throws Exception { public void testDurableStoreAndForwardReconnect() throws Exception {
// create a local durable consumer // create a local durable consumer
MessageConsumer localConsumer = localSession.createDurableSubscriber(included, consumerName); MessageConsumer localConsumer = localSession.createDurableSubscriber(included, consumerName);
Thread.sleep(1000); Thread.sleep(5000);
// now close everything down and restart // now close everything down and restart
doTearDown(); doTearDown();
doSetUp(); doSetUp(false);
// send messages // send messages
MessageProducer producer = localSession.createProducer(included); MessageProducer producer = localSession.createProducer(included);
for (int i = 0; i < MESSAGE_COUNT; i++) { for (int i = 0; i < MESSAGE_COUNT; i++) {
Message test = localSession.createTextMessage("test-" + i); Message test = localSession.createTextMessage("test-" + i);
producer.send(test); producer.send(test);
} }
Thread.sleep(1000); Thread.sleep(5000);
// consume some messages locally // consume some messages locally
localConsumer = localSession.createDurableSubscriber(included, consumerName); localConsumer = localSession.createDurableSubscriber(included, consumerName);
LOG.info("Consume from local consumer: " + localConsumer);
for (int i = 0; i < MESSAGE_COUNT / 2; i++) { for (int i = 0; i < MESSAGE_COUNT / 2; i++) {
assertNotNull("message count: " + i, localConsumer.receive(2500)); assertNotNull("message count: " + i, localConsumer.receive(2500));
} }
Thread.sleep(1000); Thread.sleep(5000);
// close everything down and restart // close everything down and restart
doTearDown(); doTearDown();
doSetUp(); doSetUp(false);
Thread.sleep(5000);
LOG.info("Consume from remote");
// consume the rest remotely // consume the rest remotely
MessageConsumer remoteConsumer = remoteSession.createDurableSubscriber(included, consumerName); MessageConsumer remoteConsumer = remoteSession.createDurableSubscriber(included, consumerName);
LOG.info("Remote consumer: " + remoteConsumer);
Thread.sleep(5000);
for (int i = 0; i < MESSAGE_COUNT / 2; i++) { for (int i = 0; i < MESSAGE_COUNT / 2; i++) {
assertNotNull("message count: " + i, remoteConsumer.receive(2500)); assertNotNull("message count: " + i, remoteConsumer.receive(10000));
} }
} }
@Override @Before
protected void setUp() throws Exception { public void setUp() throws Exception {
setAutoFail(true); doSetUp(true);
super.setUp();
doSetUp();
} }
@Override @After
protected void tearDown() throws Exception { public void tearDown() throws Exception {
localBroker.deleteAllMessages();
remoteBroker.deleteAllMessages();
doTearDown(); doTearDown();
super.tearDown();
} }
protected void doTearDown() throws Exception { protected void doTearDown() throws Exception {
@ -211,11 +228,13 @@ public class SimpleNetworkTest extends org.apache.activemq.TestSupport {
remoteBroker.stop(); remoteBroker.stop();
} }
protected void doSetUp() throws Exception { protected void doSetUp(boolean deleteAllMessages) throws Exception {
remoteBroker = createRemoteBroker(); remoteBroker = createRemoteBroker();
remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
remoteBroker.start(); remoteBroker.start();
remoteBroker.waitUntilStarted(); remoteBroker.waitUntilStarted();
localBroker = createLocalBroker(); localBroker = createLocalBroker();
localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
localBroker.start(); localBroker.start();
localBroker.waitUntilStarted(); localBroker.waitUntilStarted();
URI localURI = localBroker.getVmConnectorURI(); URI localURI = localBroker.getVmConnectorURI();
@ -223,12 +242,12 @@ public class SimpleNetworkTest extends org.apache.activemq.TestSupport {
fac.setAlwaysSyncSend(true); fac.setAlwaysSyncSend(true);
fac.setDispatchAsync(false); fac.setDispatchAsync(false);
localConnection = fac.createConnection(); localConnection = fac.createConnection();
localConnection.setClientID("local"); localConnection.setClientID("clientId");
localConnection.start(); localConnection.start();
URI remoteURI = remoteBroker.getVmConnectorURI(); URI remoteURI = remoteBroker.getVmConnectorURI();
fac = new ActiveMQConnectionFactory(remoteURI); fac = new ActiveMQConnectionFactory(remoteURI);
remoteConnection = fac.createConnection(); remoteConnection = fac.createConnection();
remoteConnection.setClientID("remote"); remoteConnection.setClientID("clientId");
remoteConnection.start(); remoteConnection.start();
included = new ActiveMQTopic("include.test.bar"); included = new ActiveMQTopic("include.test.bar");
excluded = new ActiveMQTopic("exclude.test.bar"); excluded = new ActiveMQTopic("exclude.test.bar");

View File

@ -24,7 +24,7 @@
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker brokerName="localBroker" persistent="true" useShutdownHook="false" xmlns="http://activemq.apache.org/schema/core"> <broker brokerName="localBroker" start="false" persistent="true" useShutdownHook="false" xmlns="http://activemq.apache.org/schema/core">
<networkConnectors> <networkConnectors>
<networkConnector uri="static:(tcp://localhost:61617)" <networkConnector uri="static:(tcp://localhost:61617)"
duplex="true" duplex="true"

View File

@ -23,7 +23,7 @@
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker brokerName="localBroker" persistent="true" useShutdownHook="false" monitorConnectionSplits="true" xmlns="http://activemq.apache.org/schema/core"> <broker brokerName="localBroker" start="false" persistent="true" useShutdownHook="false" monitorConnectionSplits="true" xmlns="http://activemq.apache.org/schema/core">
<networkConnectors> <networkConnectors>
<networkConnector uri="static:(tcp://localhost:61617)" <networkConnector uri="static:(tcp://localhost:61617)"
dynamicOnly = "false" dynamicOnly = "false"

View File

@ -22,7 +22,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<broker brokerName="localBroker" persistent="true" useShutdownHook="false" xmlns="http://activemq.apache.org/schema/core"> <broker brokerName="localBroker" start="false" persistent="true" useShutdownHook="false" xmlns="http://activemq.apache.org/schema/core">
<transportConnectors><transportConnector uri="tcp://localhost:61616" discoveryUri="multicast://224.1.2.6:6123" /></transportConnectors> <transportConnectors><transportConnector uri="tcp://localhost:61616" discoveryUri="multicast://224.1.2.6:6123" /></transportConnectors>

View File

@ -22,7 +22,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<broker brokerName="remoteBroker" persistent="true" useShutdownHook="false" xmlns="http://activemq.apache.org/schema/core"> <broker brokerName="remoteBroker" start="false" persistent="true" useShutdownHook="false" xmlns="http://activemq.apache.org/schema/core">
<transportConnectors><transportConnector uri="tcp://localhost:61617" discoveryUri="multicast://224.1.2.6:6123" /></transportConnectors> <transportConnectors><transportConnector uri="tcp://localhost:61617" discoveryUri="multicast://224.1.2.6:6123" /></transportConnectors>

View File

@ -24,7 +24,7 @@
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker brokerName="remoteBroker" useJmx="false" persistent="true" useShutdownHook="false" monitorConnectionSplits="true" xmlns="http://activemq.apache.org/schema/core"> <broker brokerName="remoteBroker" start="false" useJmx="false" persistent="true" useShutdownHook="false" monitorConnectionSplits="false" xmlns="http://activemq.apache.org/schema/core">
<networkConnectors> <networkConnectors>
<networkConnector uri="static:(tcp://localhost:61616)" /> <networkConnector uri="static:(tcp://localhost:61616)" />
</networkConnectors> </networkConnectors>