Package org.codehaus.activemq.broker

Examples of org.codehaus.activemq.broker.BrokerContainer


      }
    }

    public synchronized void doStop() throws WaitingException, Exception {
        if (container != null) {
            BrokerContainer temp = container;
            container = null;
            temp.stop();
        }
    }
View Full Code Here


        }
    }

    public synchronized void doFail() {
        if (container != null) {
            BrokerContainer temp = container;
            container = null;
            try {
                temp.stop();
            }
            catch (JMSException e) {
                log.info("Caught while closing due to failure: " + e, e);
            }
        }
View Full Code Here

    protected MessageConsumer createMessageConsumer(Session session, Destination destination) throws JMSException{
        return session.createConsumer(destination);
    }

    protected ActiveMQConnectionFactory createGenericClusterFactory(String brokerName) throws JMSException {
        BrokerContainer container = new BrokerContainerImpl(brokerName);
        ZeroconfDiscoveryAgent agent = new ZeroconfDiscoveryAgent();
        agent.setType(getClass().getName() + ".");
        container.setDiscoveryAgent(agent);
        String url = "tcp://localhost:0";
        container.addConnector(url);
        container.addNetworkConnector(new DiscoveryNetworkConnector(container));
        container.start();
        //embedded brokers are resolved by url - so make url unique
        //this confused me tests for a while :-)
        return new ActiveMQConnectionFactory(container,"vm://"+brokerName);
    }
View Full Code Here

                System.out.println("Loading Message Broker from file: " + file);
                factory.setResource(new FileSystemResource(file));
            }


            BrokerContainer container = factory.createBrokerContainer("DefaultBroker", BrokerContext.getInstance());
            container.start();

            // lets wait until we're killed.
            Object lock = new Object();
            synchronized (lock) {
                lock.wait();
View Full Code Here

        Object value = factory.getBean("broker");

        assertTrue("Should have created a broker!", value != null);
        assertTrue("Should be a broker container: " + value, value instanceof BrokerContainer);

        BrokerContainer container = (BrokerContainer) value;
        Broker broker = container.getBroker();
        assertTrue("Should have a broker!", broker != null);

        assertEquals("Broker name not set!", "localhost", broker.getBrokerName());

        Object transport = factory.getBean("transport");
        assertTrue("Made transport", transport != null);

        List connectors = container.getTransportConnectors();
        assertEquals("Should have created more connectors", 3, connectors.size());

        BrokerConnectorImpl connector1 = (BrokerConnectorImpl) connectors.get(0);
        TransportServerChannel serverChannel1 = connector1.getServerChannel();
        assertTrue(serverChannel1 instanceof VmTransportServerChannel);

        BrokerConnectorImpl connector2 = (BrokerConnectorImpl) connectors.get(1);
        TransportServerChannel serverChannel2 = connector2.getServerChannel();
        assertTrue(serverChannel2 instanceof TcpTransportServerChannel);
        TcpTransportServerChannel tcpChannel2 = (TcpTransportServerChannel) serverChannel2;
        assertEquals("backlog", 1000, tcpChannel2.getBacklog());
        assertEquals("maxOutstandingMessages", 50, tcpChannel2.getMaxOutstandingMessages());
        assertTrue("useAsyncSend", tcpChannel2.isUseAsyncSend());


        List networkConnectors = container.getNetworkConnectors();
        assertEquals("Should have a single network connector", 1, networkConnectors.size());
        NetworkConnector networkConnector = (NetworkConnector) networkConnectors.get(0);

        List networkChannels = networkConnector.getNetworkChannels();
        assertEquals("Should have 2 network channels", 2, networkChannels.size());
View Full Code Here

    }

    protected BrokerContainer createBroker(BrokerContainerFactory factory) throws JMSException {
        assertTrue("Factory is null", factory != null);
        String brokerName = getName();
        BrokerContainer container = factory.createBrokerContainer(brokerName, BrokerContext.getInstance());

        assertTrue("Should have a broker container!", container != null);

        Broker broker = container.getBroker();
        assertTrue("Should have a broker!", broker != null);

        assertEquals("Broker name not set!", brokerName, broker.getBrokerName());

        container.start();
        container.stop();
        return container;
    }
View Full Code Here

            String url = ActiveMQConnection.DEFAULT_URL;
            if (args.length > 0) {
                url = args[0];
            }

            BrokerContainer container = new BrokerContainerImpl();
            container.addConnector(url);

            if (args.length > 1) {
                container.addNetworkConnector(args[1]);
            }

            container.start();

            // lets wait until we're killed.
            Object lock = new Object();
            synchronized (lock) {
                lock.wait();
View Full Code Here

        }
    }

    public synchronized void doStop() throws WaitingException, Exception {
        if (container != null) {
            BrokerContainer temp = container;
            container = null;
            temp.stop();
        }
    }
View Full Code Here

        }
    }

    public synchronized void doFail() {
        if (container != null) {
            BrokerContainer temp = container;
            container = null;
            try {
                temp.stop();
            }
            catch (JMSException e) {
                log.info("Caught while closing due to failure: " + e, e);
            }
        }
View Full Code Here

                System.out.println("Loading Message Broker from file: " + file);
                factory.setResource(new FileSystemResource(file));
            }

            IdGenerator idgen = new IdGenerator();
            BrokerContainer container = factory.createBrokerContainer(idgen.generateId(), BrokerContext.getInstance());
            container.start();

            // lets wait until we're killed.
            Object lock = new Object();
            synchronized (lock) {
                lock.wait();
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.broker.BrokerContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.