1 18 package org.apache.activemq.usecases; 19 20 import org.apache.activemq.ActiveMQConnectionFactory; 21 import org.apache.activemq.broker.BrokerService; 22 23 import javax.jms.JMSException ; 24 25 28 public class TwoBrokerTopicSendReceiveUsingJavaConfigurationTest extends TwoBrokerTopicSendReceiveTest { 29 BrokerService receiveBroker; 30 BrokerService sendBroker; 31 32 protected ActiveMQConnectionFactory createReceiverConnectionFactory() throws JMSException { 33 try { 34 receiveBroker = new BrokerService(); 35 receiveBroker.setUseJmx(false); 36 receiveBroker.setPersistent(false); 37 receiveBroker.addConnector("tcp://localhost:62002"); 38 receiveBroker.addNetworkConnector("static:failover:tcp://localhost:62001"); 39 receiveBroker.start(); 40 41 ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62002"); 42 return factory; 43 } catch (Exception e) { 44 e.printStackTrace(); 45 return null; 46 } 47 } 48 49 protected ActiveMQConnectionFactory createSenderConnectionFactory() throws JMSException { 50 try { 51 sendBroker = new BrokerService(); 52 sendBroker.setUseJmx(false); 53 sendBroker.setPersistent(false); 54 sendBroker.addConnector("tcp://localhost:62001"); 55 sendBroker.addNetworkConnector("static:failover:tcp://localhost:62002"); 56 sendBroker.start(); 57 58 ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62001"); 59 return factory; 60 } catch (Exception e) { 61 e.printStackTrace(); 62 return null; 63 } 64 } 65 66 protected void tearDown() throws Exception { 67 super.tearDown(); 68 if (sendBroker != null) { 69 sendBroker.stop(); 70 } 71 if (receiveBroker != null) { 72 receiveBroker.stop(); 73 } 74 } 75 76 } 77 | Popular Tags |