public MessageInterceptorRegistry get(String brokerName){ BrokerService brokerService = BrokerRegistry.getInstance().lookup(brokerName); return get(brokerService); }
private MessageInterceptorRegistry(){ this.brokerService=BrokerRegistry.getInstance().findFirst(); messageInterceptorRegistryMap.put(brokerService,this); }
final BrokerRegistry brokerRegistry = BrokerRegistry.getInstance(); if (brokerRegistry.lookup(getBrokerName()) == null) { brokerRegistry.bind(getBrokerName(), BrokerService.this); brokerRegistry.bind(getBrokerName(), BrokerService.this); } catch (Exception e) { LOG.error("Failed to start Apache ActiveMQ ({}, {})", getBrokerName(), brokerId, e);
synchronized(registry.getRegistryMutext()) { broker = registry.lookup(brokerName); if (broker == null || waitForStart > 0) { final long expiry = System.currentTimeMillis() + waitForStart; try { LOG.debug("waiting for broker named: " + brokerName + " to enter registry"); registry.getRegistryMutext().wait(timeout); broker = registry.lookup(brokerName); } catch (InterruptedException ignored) {
synchronized (BrokerRegistry.getInstance().getRegistryMutext()) { broker = lookupBroker(BrokerRegistry.getInstance(), host, waitForStart); if (broker == null) { if (!create) { BrokerRegistry.getInstance().getRegistryMutext().notifyAll();
BrokerRegistry.getInstance().unbind(getBrokerName()); VMTransportFactory.stopped(getBrokerName()); if (broker != null) {
adminView.setBroker(managedBroker); BrokerRegistry.getInstance().bind(getBrokerName(), 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; }
synchronized (BrokerRegistry.getInstance().getRegistryMutext()) { broker = lookupBroker(BrokerRegistry.getInstance(), host, waitForStart); if (broker == null) { if (!create) { BrokerRegistry.getInstance().getRegistryMutext().notifyAll();
BrokerRegistry.getInstance().unbind(getBrokerName()); VMTransportFactory.stopped(getBrokerName()); if (broker != null) {
/** * @param registry * @param brokerName * @param waitForStart - time in milliseconds to wait for a broker to appear * @return */ private BrokerService lookupBroker(final BrokerRegistry registry, final String brokerName, int waitForStart) { BrokerService broker = null; synchronized(registry.getRegistryMutext()) { broker = registry.lookup(brokerName); if (broker == null && waitForStart > 0) { final long expiry = System.currentTimeMillis() + waitForStart; while (broker == null && expiry > System.currentTimeMillis()) { long timeout = Math.max(0, expiry - System.currentTimeMillis()); try { LOG.debug("waiting for broker named: " + brokerName + " to start"); registry.getRegistryMutext().wait(timeout); } catch (InterruptedException ignored) { } broker = registry.lookup(brokerName); } } } return broker; }
/** * @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 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; } }
@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); brokerRegistry.bind(getBrokerName(), BrokerService.this); } catch (Exception e) { LOG.error("Failed to start Apache ActiveMQ ({}, {})", getBrokerName(), brokerId, e);
synchronized (BrokerRegistry.getInstance().getRegistryMutext()) { broker = lookupBroker(BrokerRegistry.getInstance(), host, waitForStart); if (broker == null) { if (!create) { BrokerRegistry.getInstance().getRegistryMutext().notifyAll();
BrokerRegistry.getInstance().unbind(getBrokerName()); VMTransportFactory.stopped(getBrokerName()); if (broker != null) {
synchronized(registry.getRegistryMutext()) { broker = registry.lookup(brokerName); if (broker == null || waitForStart > 0) { final long expiry = System.currentTimeMillis() + waitForStart; try { LOG.debug("waiting for broker named: " + brokerName + " to enter registry"); registry.getRegistryMutext().wait(timeout); broker = registry.lookup(brokerName); } catch (InterruptedException ignored) {
/** * @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; }
/** * 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"); } }