use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class RequestReplyNoAdvisoryNetworkTest method doTestNonAdvisoryNetworkRequestReply.
public void doTestNonAdvisoryNetworkRequestReply() throws Exception {
waitForBridgeFormation(a, 1, 0);
waitForBridgeFormation(b, 1, 0);
ActiveMQConnectionFactory sendFactory = createConnectionFactory(a);
ActiveMQConnection sendConnection = createConnection(sendFactory);
ActiveMQSession sendSession = (ActiveMQSession) sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = sendSession.createProducer(sendQ);
ActiveMQTempQueue realReplyQ = (ActiveMQTempQueue) sendSession.createTemporaryQueue();
TextMessage message = sendSession.createTextMessage("1");
message.setJMSReplyTo(realReplyQ);
producer.send(message);
LOG.info("request sent");
// responder
ActiveMQConnectionFactory consumerFactory = createConnectionFactory(b);
ActiveMQConnection consumerConnection = createConnection(consumerFactory);
ActiveMQSession consumerSession = (ActiveMQSession) consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = consumerSession.createConsumer(sendQ);
TextMessage received = (TextMessage) consumer.receive(receiveTimeout);
assertNotNull("got request from sender ok", received);
LOG.info("got request, sending reply");
MessageProducer consumerProducer = consumerSession.createProducer(received.getJMSReplyTo());
consumerProducer.send(consumerSession.createTextMessage("got " + received.getText()));
// temp dest on reply broker tied to this connection, setOptimizedDispatch=true ensures
// message gets delivered before destination is removed
consumerConnection.close();
// reply consumer
MessageConsumer replyConsumer = sendSession.createConsumer(realReplyQ);
TextMessage reply = (TextMessage) replyConsumer.receive(receiveTimeout);
assertNotNull("expected reply message", reply);
assertEquals("text is as expected", "got 1", reply.getText());
sendConnection.close();
LOG.info("checking for dangling temp destinations");
// ensure all temp dests get cleaned up on all brokers
for (BrokerService brokerService : brokers) {
final RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker();
assertTrue("all temps are gone on " + regionBroker.getBrokerName(), Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
Map<?, ?> tempTopics = regionBroker.getTempTopicRegion().getDestinationMap();
LOG.info("temp topics on " + regionBroker.getBrokerName() + ", " + tempTopics);
Map<?, ?> tempQ = regionBroker.getTempQueueRegion().getDestinationMap();
LOG.info("temp queues on " + regionBroker.getBrokerName() + ", " + tempQ);
return tempQ.isEmpty() && tempTopics.isEmpty();
}
}));
}
}
use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class TwoBrokerVirtualTopicForwardingTest method createAndConfigureBroker.
private BrokerService createAndConfigureBroker(URI uri) throws Exception {
BrokerService broker = createBroker(uri);
configurePersistenceAdapter(broker);
return broker;
}
use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class TwoBrokerTopicSendReceiveTest method tearDown.
@Override
protected void tearDown() throws Exception {
super.tearDown();
for (Iterator<BrokerService> iter = brokers.values().iterator(); iter.hasNext(); ) {
BrokerService broker = iter.next();
ServiceSupport.dispose(broker);
iter.remove();
}
}
use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class TwoBrokerTopicSendReceiveUsingJavaConfigurationTest method createReceiverConnectionFactory.
@Override
protected ActiveMQConnectionFactory createReceiverConnectionFactory() throws JMSException {
try {
receiveBroker = new BrokerService();
receiveBroker.setBrokerName("receiveBroker");
receiveBroker.setUseJmx(false);
receiveBroker.setPersistent(false);
receiveBroker.addConnector("tcp://localhost:62002");
receiveBroker.addNetworkConnector("static:failover:tcp://localhost:62001");
receiveBroker.start();
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62002");
return factory;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class TwoBrokerVirtualDestDinamicallyIncludedDestTest method createAndConfigureBroker.
private BrokerService createAndConfigureBroker(URI uri) throws Exception {
BrokerService broker = createBroker(uri);
configurePersistenceAdapter(broker);
// make all topics virtual and consumers use the default prefix
VirtualDestinationInterceptor virtualDestinationInterceptor = new VirtualDestinationInterceptor();
VirtualTopic vTopic = new VirtualTopic();
vTopic.setLocal(true);
virtualDestinationInterceptor.setVirtualDestinations(new VirtualDestination[] { vTopic });
DestinationInterceptor[] destinationInterceptors = new DestinationInterceptor[] { virtualDestinationInterceptor };
broker.setDestinationInterceptors(destinationInterceptors);
return broker;
}
Aggregations