Package org.apache.activemq.jms.pool

Examples of org.apache.activemq.jms.pool.PooledConnection


    public void testEnhancedConnection() throws Exception {
        XaPooledConnectionFactory pooledFactory =
                new XaPooledConnectionFactory(new ActiveMQXAConnectionFactory("mock:" + connector.getConnectUri() + "?closeAsync=false"));

        PooledConnection connection = (PooledConnection) pooledFactory.createConnection();
        EnhancedConnection enhancedConnection = (EnhancedConnection)connection.getConnection();
        DestinationSource destinationSource = enhancedConnection.getDestinationSource();
        assertNotNull(destinationSource);

    }
View Full Code Here


        doTestEviction(pooledFactory);
    }

    public void doTestEviction(ConnectionFactory pooledFactory) throws Exception {
        PooledConnection connection = (PooledConnection) pooledFactory.createConnection();
        ActiveMQConnection amqC = (ActiveMQConnection) connection.getConnection();
        final CountDownLatch gotExceptionEvent = new CountDownLatch(1);
        amqC.addTransportListener(new TransportListener() {
            public void onCommand(Object command) {
            }
            public void onException(IOException error) {
                // we know connection is dead...
                // listeners are fired async
                gotExceptionEvent.countDown();
            }
            public void transportInterupted() {
            }
            public void transportResumed() {
            }
        });

        sendMessage(connection);
        LOG.info("sent one message worked fine");
        createConnectionFailure(connection);
        try {
            sendMessage(connection);
            TestCase.fail("Expected Error");
        } catch (JMSException e) {
        } finally {
            connection.close();
        }
        TestCase.assertTrue("exception event propagated ok", gotExceptionEvent.await(5, TimeUnit.SECONDS));
        // If we get another connection now it should be a new connection that
        // works.
        LOG.info("expect new connection after failure");
View Full Code Here

            threads[i] = new Thread(new Runnable() {
                @Override
                public void run() {
                    while (!done.get() && latch.getCount() > 0) {
                        try {
                            final PooledConnection pooledConnection = (PooledConnection) pooled.createConnection();
                            if (pooledConnection.getConnection() == null) {
                                LOG.info("Found broken connection.");
                                latch.countDown();
                            }
                            pooledConnection.close();
                        } catch (JMSException e) {
                            LOG.warn("Caught Exception", e);
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.activemq.jms.pool.PooledConnection

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.