:) It's the mailing list software conspiring, I tell you... adding it directly into the mail instead:
package org.example.activemq; import java.util.Enumeration; import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.network.NetworkConnector; import org.apache.activemq.store.memory.MemoryPersistenceAdapter; public class NetworkTest extends TestCase { public void testNetworkOfBrokers() throws Exception { BrokerService brokerService1 = null; BrokerService brokerService2 = null; try { { brokerService1 = new BrokerService(); brokerService1.setBrokerName("one"); brokerService1.setUseJmx(false); brokerService1.setPersistenceAdapter(new MemoryPersistenceAdapter()); brokerService1.addConnector("tcp://0.0.0.0:61616"); NetworkConnector network1 = brokerService1.addNetworkConnector("static:(tcp://localhost:51515)"); network1.setName("network1"); network1.setDynamicOnly(true); network1.setNetworkTTL(3); network1.setPrefetchSize(1); brokerService1.start(); } { brokerService2 = new BrokerService(); brokerService2.setBrokerName("two"); brokerService2.setUseJmx(false); brokerService2.setPersistenceAdapter(new MemoryPersistenceAdapter()); brokerService2.addConnector("tcp://0.0.0.0:51515"); NetworkConnector network2 = brokerService2.addNetworkConnector("static:(tcp://localhost:61616)"); network2.setName("network2"); network2.setDynamicOnly(true); network2.setNetworkTTL(3); network2.setPrefetchSize(1); brokerService2.start(); } ActiveMQConnectionFactory connectionFactory1 = new ActiveMQConnectionFactory("failover:(tcp://localhost:61616,tcp://localhost:51515)?randomize=false"); ActiveMQConnectionFactory connectionFactory2 = new ActiveMQConnectionFactory("failover:(tcp://localhost:51515,tcp://localhost:61616)?randomize=false"); Connection connection1 = connectionFactory1.createConnection(); connection1.start(); Connection connection2 = connectionFactory2.createConnection(); connection2.start(); try { Session session1 = connection1.createSession(true, Session.AUTO_ACKNOWLEDGE); Session session2 = connection1.createSession(true, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer1 = session1.createConsumer(new ActiveMQQueue("testingqueue")); MessageProducer producer2 = session2.createProducer(new ActiveMQQueue("testingqueue")); TextMessage message2 = session2.createTextMessage(); message2.setText("Hello World!"); producer2.send(message2); Message message1 = consumer1.receive(1000); assertNotNull(message1); System.out.println(message1); QueueBrowser browser = session2.createBrowser(new ActiveMQQueue("testingqueue")); Enumeration<?> enumeration = browser.getEnumeration(); assertFalse(enumeration.hasMoreElements()); } finally { connection1.stop(); connection2.stop(); } } finally { try { if(brokerService1 != null) { brokerService1.stop(); }} catch(Throwable t) { t.printStackTrace(); } try { if(brokerService2 != null) { brokerService2.stop(); }} catch(Throwable t) { t.printStackTrace(); } } } } On Fri, Apr 16, 2010 at 6:56 PM, Tracy Snell <tsn...@gmail.com> wrote: > You did do something wrong! You forgot to attach the test case :) > > On Apr 16, 2010, at 11:59 AM, Jamie McCrindle wrote: > >> Hiya, >> >> We've been getting an issue with using a static Network of Brokers >> where if we publish something to broker 1, it doesn't get picked up by >> broker 2. We've tried various values for dynamicOnly, networkTTL and >> prefetchSize. >> >> I've attached a test case that, assuming I've written it correctly, >> highlights the issue. I can raise it in JIRA but I thought I'd send it >> to the message list first in case I've done something obviously wrong. >> >> I'm using ActiveMQ 5.3.1 >> >> cheers, >> j. > >