Package org.apache.activemq

Examples of org.apache.activemq.ActiveMQConnection


        } else {
            if (activationSpec.isDurableSubscription()) {
                log.warn("No clientID specified for durable subscription: " + activationSpec);
            }
        }
        ActiveMQConnection physicalConnection = (ActiveMQConnection) cf.createConnection(userName, password);

        // have we configured a redelivery policy
        RedeliveryPolicy redeliveryPolicy = activationSpec.redeliveryPolicy();
        if (redeliveryPolicy != null) {
            physicalConnection.setRedeliveryPolicy(redeliveryPolicy);
        }
        return physicalConnection;
    }
View Full Code Here


        public static boolean recover(ActiveMQResourceManager rm) throws IOException {
            if (isRecoverable(rm)) {
                try {
                    ActiveMQConnectionFactory connFactory = (ActiveMQConnectionFactory) rm.getConnectionFactory();
                    ActiveMQConnection activeConn = (ActiveMQConnection)connFactory.createConnection();
                    ActiveMQSession session = (ActiveMQSession)activeConn.createSession(true, Session.SESSION_TRANSACTED);
                    NamedXAResource namedXaResource = new WrapperNamedXAResource(session.getTransactionContext(), rm.getResourceName());

                    RecoverableTransactionManager rtxManager = (RecoverableTransactionManager) rm.getTransactionManager();
                    rtxManager.recoverResourceManager(namedXaResource);
                    return true;
View Full Code Here

            ActiveMQConnectionRequestInfo connectionRequestInfo,
            ActiveMQConnectionFactory connectionFactory) throws JMSException
    {
        String userName = connectionRequestInfo.getUserName();
        String password = connectionRequestInfo.getPassword();
        ActiveMQConnection physicalConnection = (ActiveMQConnection) connectionFactory.createConnection(userName, password);

        String clientId = connectionRequestInfo.getClientid();
        if ( clientId != null && clientId.length() > 0 )
        {
            physicalConnection.setClientID(clientId);
        }
        return physicalConnection;
    }
View Full Code Here

    }

    public void testEvictionOfIdle() throws Exception {
        pooledFactory.setIdleTimeout(10);
        PooledConnection connection = (PooledConnection) pooledFactory.createConnection();
        ActiveMQConnection amq1 = connection.getConnection();
       
        connection.close();
        // let it idle timeout
        TimeUnit.SECONDS.sleep(1);
       
        PooledConnection connection2 = (PooledConnection) pooledFactory.createConnection();
        ActiveMQConnection amq2 = connection2.getConnection();
        assertTrue("not equal", !amq1.equals(amq2));
    }
View Full Code Here

   
   
    public void testEvictionOfExpired() throws Exception {
        pooledFactory.setExpiryTimeout(10);
        Connection connection = pooledFactory.createConnection();
        ActiveMQConnection amq1 = ((PooledConnection) connection).getConnection();
       
        // let it expire while in use
        TimeUnit.SECONDS.sleep(1);
        connection.close();
       
        Connection connection2 = pooledFactory.createConnection();
        ActiveMQConnection amq2 = ((PooledConnection) connection2).getConnection();
        assertTrue("not equal", !amq1.equals(amq2));
    }
View Full Code Here

        pooledFactory = new PooledConnectionFactory(factory);
    }

    public void testEviction() throws Exception {
        PooledConnection connection = (PooledConnection) pooledFactory.createConnection();
        ActiveMQConnection amqC = 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
View Full Code Here

        Connection connection2 = pooledFactory.createConnection();
        sendMessage(connection2);
    }

    private void createConnectionFailure(Connection connection) throws Exception {
        ActiveMQConnection c = ((PooledConnection)connection).getConnection();
        MockTransport t = (MockTransport)c.getTransportChannel().narrow(MockTransport.class);
        t.onException(new IOException("forcing exception for " + getName() + " to force pool eviction"));
        LOG.info("arranged for failure, chucked exception");
    }
View Full Code Here

        PooledConnectionFactory pcf = new PooledConnectionFactory();
        String uri = proxy.getUrl().toString() + "?trace=true&wireFormat.maxInactivityDuration=500&wireFormat.maxInactivityDurationInitalDelay=500";
        pcf.setConnectionFactory(new ActiveMQConnectionFactory(uri));
       
        PooledConnection conn =  (PooledConnection) pcf.createConnection();
        ActiveMQConnection amq = conn.getConnection();
        final CountDownLatch gotException = new CountDownLatch(1);
        //amq.set
        conn.setExceptionListener(new ExceptionListener() {
            public void onException(JMSException exception) {
                gotException.countDown();
View Full Code Here

        copy(copy);
        return copy;
    }

    private void copy(ActiveMQObjectMessage copy) {
        ActiveMQConnection connection = getConnection();
        if (connection == null || !connection.isObjectMessageSerializationDefered()) {
            storeContent();
            copy.object = null;
        } else {
            copy.object = object;
        }
View Full Code Here

        ByteSequence bodyAsBytes = getContent();
        if (bodyAsBytes == null && object != null) {
            try {
                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
                OutputStream os = bytesOut;
                ActiveMQConnection connection = getConnection();
                if (connection != null && connection.isUseCompression()) {
                    compressed = true;
                    os = new DeflaterOutputStream(os);
                }
                DataOutputStream dataOut = new DataOutputStream(os);
                ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
View Full Code Here

TOP

Related Classes of org.apache.activemq.ActiveMQConnection

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.