private MessageInterceptorRegistry(){ this.brokerService=BrokerRegistry.getInstance().findFirst(); messageInterceptorRegistryMap.put(brokerService,this); }
/** * @param brokerName * @return the BrokerService */ public BrokerService lookup(String brokerName) { BrokerService result = null; synchronized (mutex) { result = brokers.get(brokerName); if (result == null && brokerName != null && brokerName.equals(BrokerService.DEFAULT_BROKER_NAME)) { result = findFirst(); if (result != null) { LOG.warn("Broker localhost not started so using {} instead", result.getBrokerName()); } } if (result == null && (brokerName==null || brokerName.isEmpty() || brokerName.equals("null"))){ result = findFirst(); } } 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); }
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()); }
final MessageInterceptorRegistry registry = MessageInterceptorRegistry.getInstance().get(BrokerRegistry.getInstance().findFirst()); registry.addMessageInterceptorForTopic(">", new MessageInterceptor() { @Override
protected static BrokerService findSingletonBroker() { BrokerService broker = BrokerRegistry.getInstance().findFirst(); if (broker == null) { throw new IllegalArgumentException("No BrokerService is registered with the BrokerRegistry. Are you sure there is a configured broker in the same ClassLoader?"); } return broker; } }
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); }
/** * @param brokerName * @return the BrokerService */ public BrokerService lookup(String brokerName) { BrokerService result = null; synchronized (mutex) { result = brokers.get(brokerName); if (result == null && brokerName != null && brokerName.equals(BrokerService.DEFAULT_BROKER_NAME)) { result = findFirst(); if (result != null) { LOG.warn("Broker localhost not started so using {} instead", result.getBrokerName()); } } if (result == null && (brokerName==null || brokerName.isEmpty() || brokerName.equals("null"))){ result = findFirst(); } } return result; }
/** * @param brokerName * @return the BrokerService */ public BrokerService lookup(String brokerName) { BrokerService result = null; synchronized (mutex) { result = brokers.get(brokerName); if (result == null && brokerName != null && brokerName.equals(BrokerService.DEFAULT_BROKER_NAME)) { result = findFirst(); if (result != null) { LOG.warn("Broker localhost not started so using {} instead", result.getBrokerName()); } } if (result == null && (brokerName==null || brokerName.isEmpty() || brokerName.equals("null"))){ result = findFirst(); } } return result; }
/** * @param brokerName * @return the BrokerService */ public BrokerService lookup(String brokerName) { BrokerService result = null; synchronized (mutex) { result = brokers.get(brokerName); if (result == null && brokerName != null && brokerName.equals(BrokerService.DEFAULT_BROKER_NAME)) { result = findFirst(); if (result != null) { LOG.warn("Broker localhost not started so using {} instead", result.getBrokerName()); } } if (result == null && (brokerName==null || brokerName.isEmpty() || brokerName.equals("null"))){ result = findFirst(); } } return result; }
/** * @param brokerName * @return the BrokerService */ public BrokerService lookup(String brokerName) { BrokerService result = null; synchronized (mutex) { result = brokers.get(brokerName); if (result == null && brokerName != null && brokerName.equals(BrokerService.DEFAULT_BROKER_NAME)) { result = findFirst(); if (result != null) { LOG.warn("Broker localhost not started so using " + result.getBrokerName() + " instead"); } } } return result; }