public void testJMX() throws Exception { clearSelectorCacheFiles(); // borkerA is local and brokerB is remote bridgeAndConfigureBrokers("BrokerA", "BrokerB"); startAllBrokers(); waitForBridgeFormation(); createConsumer( "BrokerB", createDestination("Consumer.B.VirtualTopic.tempTopic", false), "foo = 'bar'"); final BrokerService brokerA = brokers.get("BrokerA").broker; String testQueue = "queue://Consumer.B.VirtualTopic.tempTopic"; VirtualDestinationSelectorCacheViewMBean cache = getVirtualDestinationSelectorCacheMBean(brokerA); Set<String> selectors = cache.selectorsForDestination(testQueue); assertEquals(1, selectors.size()); assertTrue(selectors.contains("foo = 'bar'")); boolean removed = cache.deleteSelectorForDestination(testQueue, "foo = 'bar'"); assertTrue(removed); selectors = cache.selectorsForDestination(testQueue); assertEquals(0, selectors.size()); createConsumer( "BrokerB", createDestination("Consumer.B.VirtualTopic.tempTopic", false), "ceposta = 'redhat'"); Wait.waitFor( new Wait.Condition() { Destination dest = brokerA.getDestination(new ActiveMQQueue("Consumer.B.VirtualTopic.tempTopic")); @Override public boolean isSatisified() throws Exception { return dest.getConsumers().size() == 2; } }, 500); selectors = cache.selectorsForDestination(testQueue); assertEquals(1, selectors.size()); cache.deleteAllSelectorsForDestination(testQueue); selectors = cache.selectorsForDestination(testQueue); assertEquals(0, selectors.size()); }
@Override protected Message createMessage(int i) throws Exception { TextMessage msg = createTextMessage(this.session, "Message-" + i); if (selectors.size() > 0) { String value = getRandomKey(); msg.setStringProperty("SYMBOL", value); AtomicInteger currentCount = selectorCounts.get(value); currentCount.incrementAndGet(); } return msg; }