private MessageInterceptorRegistry(){ this.brokerService=BrokerRegistry.getInstance().findFirst(); messageInterceptorRegistryMap.put(brokerService,this); }
/** * @param brokerName * @return the BrokerService */ public MessageBrokerView lookup(String brokerName) { MessageBrokerView result = null; synchronized (mutex) { result = brokerViews.get(brokerName); if (result==null){ BrokerService brokerService = BrokerRegistry.getInstance().lookup(brokerName); if (brokerService != null){ result = new MessageBrokerView(brokerService); brokerViews.put(brokerName,result); } } } return result; } }
public MessageInterceptorRegistry get(String brokerName){ BrokerService brokerService = BrokerRegistry.getInstance().lookup(brokerName); return get(brokerService); }
/** * Create a view of a running Broker * @param brokerName */ public MessageBrokerView(String brokerName){ this.brokerService = BrokerRegistry.getInstance().lookup(brokerName); if (brokerService == null){ throw new NullPointerException("BrokerService is null"); } if (!brokerService.isStarted()){ throw new IllegalStateException("BrokerService " + brokerService.getBrokerName() + " is not started"); } }
private boolean validateBroker(String host) { boolean result = true; if (BROKERS.containsKey(host) || SERVERS.containsKey(host) || CONNECTORS.containsKey(host)) { // check the broker is still in the BrokerRegistry TransportConnector connector = CONNECTORS.get(host); if (BrokerRegistry.getInstance().lookup(host) == null || (connector != null && connector.getBroker().isStopped())) { result = false; // clean-up BROKERS.remove(host); SERVERS.remove(host); if (connector != null) { CONNECTORS.remove(host); if (connector != null) { ServiceSupport.dispose(connector); } } } } return result; } }
@Before public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); brokerService.start(); factory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI()); producerConnection = factory.createConnection(); producerConnection.start(); producerSession = producerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE); queue = producerSession.createQueue(getClass().getName()); producer = producerSession.createProducer(queue); }
final BrokerRegistry brokerRegistry = BrokerRegistry.getInstance(); if (brokerRegistry.lookup(getBrokerName()) == null) { brokerRegistry.bind(getBrokerName(), BrokerService.this);
synchronized (BrokerRegistry.getInstance().getRegistryMutext()) { broker = lookupBroker(BrokerRegistry.getInstance(), host, waitForStart); if (broker == null) { if (!create) { BrokerRegistry.getInstance().getRegistryMutext().notifyAll();
public void testInterceptorAll() throws Exception { MessageInterceptorRegistry registry = MessageInterceptorRegistry.getInstance().get(BrokerRegistry.getInstance().findFirst()); registry.addMessageInterceptorForTopic(topic.getTopicName(), new MessageInterceptor() { @Override public void intercept(ProducerBrokerExchange producerExchange, Message message) { //just ignore } }); final CountDownLatch latch = new CountDownLatch(messageCount); consumer.setMessageListener(new MessageListener() { @Override public void onMessage(javax.jms.Message message) { latch.countDown(); } }); for (int i = 0; i < messageCount; i++){ javax.jms.Message message = producerSession.createTextMessage("test: " + i); producer.send(message); } latch.await(timeOutInSeconds, TimeUnit.SECONDS); assertEquals(messageCount,latch.getCount()); }
@Override protected void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); brokerService.start(); factory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI()); consumerConnection = factory.createConnection(); consumerConnection.start(); producerConnection = factory.createConnection(); producerConnection.start(); consumerSession = consumerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE); topic = consumerSession.createTopic(getName()); producerSession = producerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE); consumer = consumerSession.createConsumer(topic); producer = producerSession.createProducer(topic); }
public void testNoStackOverFlow() throws Exception { final MessageInterceptorRegistry registry = MessageInterceptorRegistry.getInstance().get(BrokerRegistry.getInstance().findFirst()); registry.addMessageInterceptorForTopic(topic.getTopicName(), new MessageInterceptor() { @Override public void intercept(ProducerBrokerExchange producerExchange, Message message) { try { registry.injectMessage(producerExchange, message); } catch (Exception e) { e.printStackTrace(); } } }); final CountDownLatch latch = new CountDownLatch(messageCount); consumer.setMessageListener(new MessageListener() { @Override public void onMessage(javax.jms.Message message) { latch.countDown(); } }); for (int i = 0; i < messageCount; i++){ javax.jms.Message message = producerSession.createTextMessage("test: " + i); producer.send(message); } latch.await(timeOutInSeconds, TimeUnit.SECONDS); assertEquals(0,latch.getCount()); }
public void testReRouteAll() throws Exception { final ActiveMQQueue queue = new ActiveMQQueue("Reroute.From."+topic.getTopicName()); final MessageInterceptorRegistry registry = MessageInterceptorRegistry.getInstance().get(BrokerRegistry.getInstance().findFirst()); registry.addMessageInterceptorForTopic(topic.getTopicName(), new MessageInterceptor() { @Override public void intercept(ProducerBrokerExchange producerExchange, Message message) { message.setDestination(queue); try { registry.injectMessage(producerExchange, message); } catch (Exception e) { e.printStackTrace(); } } }); final CountDownLatch latch = new CountDownLatch(messageCount); consumer = consumerSession.createConsumer(queue); consumer.setMessageListener(new MessageListener() { @Override public void onMessage(javax.jms.Message message) { latch.countDown(); } }); for (int i = 0; i < messageCount; i++){ javax.jms.Message message = producerSession.createTextMessage("test: " + i); producer.send(message); } latch.await(timeOutInSeconds, TimeUnit.SECONDS); assertEquals(0,latch.getCount()); }
public void testReRouteAllWithNullProducerExchange() throws Exception { final ActiveMQQueue queue = new ActiveMQQueue("Reroute.From."+topic.getTopicName()); final MessageInterceptorRegistry registry = MessageInterceptorRegistry.getInstance().get(BrokerRegistry.getInstance().findFirst()); registry.addMessageInterceptorForTopic(topic.getTopicName(), new MessageInterceptor() { @Override public void intercept(ProducerBrokerExchange producerExchange, Message message) { message.setDestination(queue); try { registry.injectMessage(producerExchange, message); } catch (Exception e) { e.printStackTrace(); } } }); final CountDownLatch latch = new CountDownLatch(messageCount); consumer = consumerSession.createConsumer(queue); consumer.setMessageListener(new MessageListener() { @Override public void onMessage(javax.jms.Message message) { latch.countDown(); } }); for (int i = 0; i < messageCount; i++){ javax.jms.Message message = producerSession.createTextMessage("test: " + i); producer.send(message); } latch.await(timeOutInSeconds, TimeUnit.SECONDS); assertEquals(0,latch.getCount()); }
BrokerRegistry.getInstance().unbind(getBrokerName()); VMTransportFactory.stopped(getBrokerName()); if (broker != null) {
final MessageInterceptorRegistry registry = MessageInterceptorRegistry.getInstance().get(BrokerRegistry.getInstance().findFirst()); registry.addMessageInterceptorForTopic(">", new MessageInterceptor() { @Override
private MessageInterceptorRegistry(){ this.brokerService=BrokerRegistry.getInstance().findFirst(); messageInterceptorRegistryMap.put(brokerService,this); }
private MessageInterceptorRegistry(){ this.brokerService=BrokerRegistry.getInstance().findFirst(); messageInterceptorRegistryMap.put(brokerService,this); }
private MessageInterceptorRegistry(){ this.brokerService=BrokerRegistry.getInstance().findFirst(); messageInterceptorRegistryMap.put(brokerService,this); }
/** * Create a view of a running Broker * @param brokerName */ public MessageBrokerView(String brokerName){ this.brokerService = BrokerRegistry.getInstance().lookup(brokerName); if (brokerService == null){ throw new NullPointerException("BrokerService is null"); } if (!brokerService.isStarted()){ throw new IllegalStateException("BrokerService " + brokerService.getBrokerName() + " is not started"); } }
public MessageInterceptorRegistry get(String brokerName){ BrokerService brokerService = BrokerRegistry.getInstance().lookup(brokerName); return get(brokerService); }