Package org.codehaus.activemq

Examples of org.codehaus.activemq.ActiveMQConnectionFactory


    public ActiveMQClusterFactory(ActiveMQConnectionFactory connectionFactory) {
        super(connectionFactory);
    }

    public ActiveMQClusterFactory(boolean transacted, int acknowledgeMode, String dataTopicPrefix, long inactiveTime) {
        super(new ActiveMQConnectionFactory(DEFAULT_CLUSTER_URL), transacted, acknowledgeMode, dataTopicPrefix, inactiveTime);
    }
View Full Code Here


        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

        addResource(session);
        return session;
    }

    protected ActiveMQConnectionFactory createFactory() {
        ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory(getUrl());
        if (embeddedBroker) {
            answer.setUseEmbeddedBroker(true);
        }
        return answer;
    }
View Full Code Here

* @version $Revision: 1.1 $
*/
public class SubscribeClosePublishThenConsumeTest extends TestSupport {

    public void testDurableTopic() throws Exception {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
        connectionFactory.setUseEmbeddedBroker(true);

        String topicName = "TestTopic";
        String clientID = "MyClientID";
        String subscriberName = "MySubscriber";

        // TODO remove this hack!
        //Connection dummy = connectionFactory.createConnection();
        //dummy.start();

        Connection connection = connectionFactory.createConnection();
        connection.setClientID(clientID);

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic topic = session.createTopic(topicName);

        // this should register a durable subscriber, we then close it to
        // test that we get messages from the producer later on
        TopicSubscriber subscriber = session.createDurableSubscriber(topic, subscriberName);
        connection.start();

        topic = null;
        subscriber.close();
        subscriber = null;

        session.close();
        session = null;

        connection.close();
        connection = null;

        // now create a new Connection, Session &  Producer, send some messages & then close
        connection = connectionFactory.createConnection();
        // connection.setClientID(clientID); // this should not be required for the Producer
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        topic = session.createTopic(topicName);
        MessageProducer producer = session.createProducer(topic);
        producer.setDeliveryMode(DeliveryMode.PERSISTENT);
        TextMessage textMessage = session.createTextMessage("Hello World");
        producer.send(textMessage);
        textMessage = null;

        topic = null;
        session.close();
        session = null;

        connection.close();
        connection = null;

        // Now (re)register the Durable subscriber, setup a listener and wait for messages that should
        // have been published by the previous producer

        connection = connectionFactory.createConnection();
        connection.setClientID(clientID);
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        topic = session.createTopic(topicName);

        subscriber = session.createDurableSubscriber(topic, subscriberName);
View Full Code Here

        assertTrue("No topic created!", topic != null);
    }

    public void testTryToReproduceNullPointerBug() throws Exception {
        String url = bindAddress;
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
        QueueConnection queueConnection = factory.createQueueConnection();
        this.connection = queueConnection;
        QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        QueueSender sender = session.createSender(null); //Unidentified
        Queue receiverQueue = session.createTemporaryQueue();
        QueueReceiver receiver = session.createReceiver(receiverQueue);
View Full Code Here

        }
        assertTrue("Unexpected count: " + count, count.get() == NUMBER);
    }

    protected QueueConnection createConnection() throws Exception {
        ActiveMQConnectionFactory factory = createConnectionFactory();
        return factory.createQueueConnection();
    }
View Full Code Here

        ActiveMQConnectionFactory factory = createConnectionFactory();
        return factory.createQueueConnection();
    }

    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
        return new ActiveMQConnectionFactory(broker, bindAddress);
    }
View Full Code Here

        receiveBroker = new BrokerContainerImpl("receiver");
        receiveBroker.addConnector("tcp://localhost:62002");
        receiveBroker.addNetworkConnector("reliable:tcp://localhost:62001");
        receiveBroker.start();

        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(receiveBroker, "tcp://localhost:62002");
        return factory;
    }
View Full Code Here

        sendBroker = new BrokerContainerImpl("sender");
        sendBroker.addConnector("tcp://localhost:62001");
        sendBroker.addNetworkConnector("reliable:tcp://localhost:62002");
        sendBroker.start();

        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(sendBroker, "tcp://localhost:62001");

        return factory;
    }
View Full Code Here

* @version $Revision: 1.1 $
*/
public class ZeroconfDiscoveryTest extends TestCase {

    public void test1() throws Exception {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("zeroconf:_activemq.broker.development.");

        // use an embedded broker configured via Spring
        connectionFactory.setUseEmbeddedBroker(true);
        connectionFactory.setBrokerContainerFactory(new SpringBrokerContainerFactory(new ClassPathResource("org/codehaus/activemq/usecases/receiver-zeroconf.xml")));

        Connection connection = connectionFactory.createConnection();
        connection.setClientID("Producer1");
        connection.start();

        // now lets close things down
        connection.close();
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.ActiveMQConnectionFactory

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.