Package org.apache.activemq

Examples of org.apache.activemq.ActiveMQConnectionFactory.createConnection()


   
    public void testMaxReconnectAttempts() throws JMSException {
        try {
            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://doesNOTexist)");
            LOG.info("Connecting.");
            Connection connection = factory.createConnection();
            connection.setClientID("test");
            fail("Did not fail to connect as expected.");
        } catch ( JMSException expected ) { 
            assertTrue("reason is  java.net.UnknownHostException", expected.getCause() instanceof  java.net.UnknownHostException);
        }
View Full Code Here


        remoteBroker.start();
        localBroker = createLocalBroker();
        localBroker.start();
        URI localURI = localBroker.getVmConnectorURI();
        ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI);
        localConnection = fac.createConnection();
        localConnection.setClientID("local");
        localConnection.start();
        URI remoteURI = remoteBroker.getVmConnectorURI();
        fac = new ActiveMQConnectionFactory(remoteURI);
        remoteConnection = fac.createConnection();
View Full Code Here

        localConnection = fac.createConnection();
        localConnection.setClientID("local");
        localConnection.start();
        URI remoteURI = remoteBroker.getVmConnectorURI();
        fac = new ActiveMQConnectionFactory(remoteURI);
        remoteConnection = fac.createConnection();
        remoteConnection.setClientID("remote");
        remoteConnection.start();
        included = new ActiveMQTopic("include.test.bar");
        excluded = new ActiveMQTopic("exclude.test.bar");
        localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
View Full Code Here

    CountDownLatch gotConnection = new CountDownLatch(1);

    public void testWaitFor() throws Exception {
        try {
            ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_NO_WAIT));
            cf.createConnection();
            fail("expect broker not exist exception");
        } catch (JMSException expectedOnNoBrokerAndNoCreate) {
        }
       
        // spawn a thread that will wait for an embedded broker to start via vm://..
View Full Code Here

        Thread t = new Thread() {
            public void run() {
                    try {
                        started.countDown();
                        ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_WAIT_FOR_START));
                        cf.createConnection();
                        gotConnection.countDown();
                  
                    } catch (Exception e) {
                        e.printStackTrace();
                        fail("unexpected exception:" + e);
View Full Code Here

        broker.start();

        stompConnect();

        ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
        connection = cf.createConnection("system", "manager");
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        queue = new ActiveMQQueue(getQueueName());
        connection.start();
    }
View Full Code Here

        broker.addConnector("stomp://localhost:61613").setName("Stomp");
        broker.addConnector("tcp://localhost:61616").setName("Default");
        broker.start();

        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
        Connection connection = factory.createConnection();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(new ActiveMQQueue(getDestinationName()));
        Message message = session.createTextMessage("Testas");
        for (int idx = 0; idx < 2000; ++idx) {
            producer.send(message);
View Full Code Here

    }

    private void consumer() throws JMSException {
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
                BROKER_URL);
        Connection connection = connectionFactory.createConnection();
        connection.start();

        Session session = connection.createSession(false,
                Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createTopic(TOPIC_NAME);
View Full Code Here

    }

    public void sendMessages(String topic) throws JMSException {
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
                BROKER_URL);
        Connection connection = connectionFactory.createConnection();
        connection.start();

        Session session = connection.createSession(false,
                Session.AUTO_ACKNOWLEDGE);
        Topic destination = session.createTopic(topic);
View Full Code Here

    }

    private void consumer(int size, String topicsToListen) throws Exception {
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
                BROKER_URL);
        Connection connection = connectionFactory.createConnection();
        connection.start();

        Session session = connection.createSession(false,
                Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createTopic(topicsToListen);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.