Package org.apache.activemq

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


            KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
            kaha.setDirectory(testDir);
            kaha.setJournalMaxFileLength(1024 * 1024);
            BrokerService broker = createBroker(kaha);
            ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
            Connection connection = cf.createConnection();
            connection.setClientID("test");
            connection.start();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            Topic topic = session.createTopic("test.topic");
            Queue queue = session.createQueue("test.queue");
View Full Code Here


       final int noConnectionToCreate = 10;
        for (int i=0; i<10;i++) {
            ActiveMQConnectionFactory factory =
                new ActiveMQConnectionFactory("discovery:(multicast://239.255.2.3:6155?group=" + group +")?closeAsync=false");
            LOG.info("Connecting.");
            Connection connection = factory.createConnection();
            connection.setClientID("test")
            connection.close();
        }
        Thread.sleep(2000);
        threads = getThreads();
View Full Code Here

    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.io.IOException, was: " + expected.getCause(), expected.getCause() instanceof java.io.IOException);
View Full Code Here

        try {
            String urlStr = "discovery:(multicast://default?group=" + groupId +
                ")?useExponentialBackOff=false&maxReconnectAttempts=2&reconnectDelay=" + initialReconnectDelay;
            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(urlStr);
            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.io.IOException, was: " + expected.getCause(), expected.getCause() instanceof java.io.IOException);
            long duration = System.currentTimeMillis() - startT;
View Full Code Here

        ignoreAllExceptionsIOExHandler.setIgnoreAllErrors(true);
        broker.setIoExceptionHandler(ignoreAllExceptionsIOExHandler);

        ActiveMQConnectionFactory f = new ActiveMQConnectionFactory("vm://localhost?async=false");
        f.setAlwaysSyncSend(true);
        Connection c = f.createConnection();
        c.start();
        Session s = c.createSession(true, Session.SESSION_TRANSACTED);
        MessageProducer p = s.createProducer(new ActiveMQQueue("Tx"));
        p.send(s.createTextMessage("aa"));
View Full Code Here

        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
        if (id != null) {
            factory.setClientID(id);
        }

        ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
        return connection;
    }

    private String generateBody(int length) {
View Full Code Here

        factory.setProducerWindowSize(48*1024);
        // ensure messages are spooled to disk for this consumer
        ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
        prefetch.setTopicPrefetch(10);
        factory.setPrefetchPolicy(prefetch);
        Connection consumerConnection = factory.createConnection();
        consumerConnection.start();

        Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer = consumerSession.createConsumer(bigDestination);

View Full Code Here

        consumerConnection.start();

        Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer = consumerSession.createConsumer(bigDestination);

        final Connection producerConnection = factory.createConnection();
        producerConnection.start();

        final int fillWithBigCount = 10;
        Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(null);
View Full Code Here

        }

        public void run(){
            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerService.getVmConnectorURI());
            try {
                Connection conn = factory.createConnection();
                conn.start();
                byte[] bytes = new byte[payLoadSize];
                for (int i = 0; i < numberOfMessages; i++) {
                    Session session = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
                    Destination destination = session.createQueue("test-queue");
View Full Code Here

        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
        // ensure messages are spooled to disk for this consumer
        ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
        prefetch.setTopicPrefetch(10);
        factory.setPrefetchPolicy(prefetch);
        Connection consumerConnection = factory.createConnection();
        consumerConnection.start();

        Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer = consumerSession.createConsumer(destination);
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.