Java Code Examples for org.apache.activemq.broker.BrokerService#getRegionBroker()
The following examples show how to use
org.apache.activemq.broker.BrokerService#getRegionBroker() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
private static Map<ActiveMQDestination, org.apache.activemq.broker.region.Destination> getDestinationMap( BrokerService target, ActiveMQDestination destination) { RegionBroker regionBroker = (RegionBroker) target.getRegionBroker(); if (destination.isTemporary()) { return destination.isQueue() ? regionBroker.getTempQueueRegion().getDestinationMap() : regionBroker.getTempTopicRegion().getDestinationMap(); } return destination.isQueue() ? regionBroker.getQueueRegion().getDestinationMap() : regionBroker.getTopicRegion().getDestinationMap(); }
Example 2
Source File: ThreeBrokerQueueNetworkTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void verifyConsumerCount(BrokerService broker, int count, final Destination dest) throws Exception { final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker(); waitFor(new Condition() { @Override public boolean isSatisified() throws Exception { return !regionBroker.getDestinations(ActiveMQDestination.transform(dest)).isEmpty(); } }); Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next(); LOG.info("Verify: consumer count on " + broker.getBrokerName() + " matches:" + count + ", val:" + internalQueue.getConsumers().size()); assertEquals("consumer count on " + broker.getBrokerName() + " matches for q: " + internalQueue, count, internalQueue.getConsumers().size()); }
Example 3
Source File: ThreeBrokerQueueNetworkTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void logConsumerCount(BrokerService broker, int count, final Destination dest) throws Exception { final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker(); waitFor(new Condition() { @Override public boolean isSatisified() throws Exception { return !regionBroker.getDestinations(ActiveMQDestination.transform(dest)).isEmpty(); } }); Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next(); LOG.info("Verify: consumer count on " + broker.getBrokerName() + " matches:" + count + ", val:" + internalQueue.getConsumers().size()); }
Example 4
Source File: ThreeBrokerQueueNetworkTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void verifyConsumePriority(BrokerService broker, byte expectedPriority, Destination dest) throws Exception { RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker(); Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next(); for (Subscription consumer : internalQueue.getConsumers()) { assertEquals("consumer on " + broker.getBrokerName() + " matches priority: " + internalQueue, expectedPriority, consumer.getConsumerInfo().getPriority()); } }
Example 5
Source File: QueueMemoryFullMultiBrokersTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void testQueueNetworkWithConsumerFull() throws Exception { bridgeAllBrokers(); startAllBrokers(); Destination dest = createDestination("TEST.FOO", false); sendMessages("Broker1", dest, 50); CountDownLatch latch = new CountDownLatch(MESSAGE_COUNT); createConsumer("Broker2", dest, latch); assertConsumersConnect("Broker1", dest, 1, 30000); sendMessages("Broker1", dest, MESSAGE_COUNT - 50); // Wait for messages to be delivered assertTrue("Missing " + latch.getCount() + " messages", latch.await(45, TimeUnit.SECONDS)); // verify stats, all messages acked BrokerService broker1 = brokers.get("Broker1").broker; RegionBroker regionBroker = (RegionBroker) broker1.getRegionBroker(); // give the acks a chance to flow Thread.sleep(2000); Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next(); assertTrue("All messages are consumed and acked from source:" + internalQueue, internalQueue.getMessages().isEmpty()); assertEquals("messages source:" + internalQueue, 0, internalQueue.getDestinationStatistics().getMessages().getCount()); assertEquals("inflight source:" + internalQueue, 0, internalQueue.getDestinationStatistics().getInflight().getCount()); }
Example 6
Source File: RequestReplyNoAdvisoryNetworkTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
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(); } })); } }