Package org.apache.qpid.client

Examples of org.apache.qpid.client.AMQConnection


            "&trust_store='%s'&trust_store_password='%s'" +
            "'";

            url = String.format(url,QpidBrokerTestCase.DEFAULT_SSL_PORT, TRUSTSTORE,TRUSTSTORE_PASSWORD);

            AMQConnection con = new AMQConnection(url);
            assertNotNull("connection should be successful", con);
            Session ssn = con.createSession(false,Session.AUTO_ACKNOWLEDGE);
            assertNotNull("create session should be successful", ssn);
        }       
    }
View Full Code Here


    {
        String url = "amqp://:@test/?brokerlist='tcp://localhost:%s?ssl='true''";

        url = String.format(url,QpidBrokerTestCase.DEFAULT_SSL_PORT);

        return new AMQConnection(url);

    }
View Full Code Here

    {
        String url = "amqp://:@test/?brokerlist='tcp://localhost:%s'";

        url = String.format(url,QpidBrokerTestCase.DEFAULT_PORT);

        return new AMQConnection(url);

    }
View Full Code Here

     * with a {@link CountDownLatch} to synchronise in the {@link #check403Exception(Throwable)} method and allow the
     * {@link #tearDown()} method to complete properly.
     */
    public Connection getConnection(String vhost, String username, String password) throws NamingException, JMSException, URLSyntaxException
    {
        AMQConnection connection = (AMQConnection) getConnection(createConnectionURL(vhost, username, password));

        //Prevent Failover
        connection.setConnectionListener(this);
       
        //QPID-2081: use a latch to sync on exception causing connection close, to work
        //around the connection close race during tearDown() causing sporadic failures
        _exceptionReceived = new CountDownLatch(1);

        connection.setExceptionListener(new ExceptionListener()
        {
            public void onException(JMSException e)
            {
                _exceptionReceived.countDown();
            }
View Full Code Here

        _monitor = new LogMonitor(_outputFile);

        super.setUp();

        _brokerUrl = getBroker().toString();
        _test = new AMQConnection(_brokerUrl, USER, USER, "clientid", "test");
        _dev = new AMQConnection(_brokerUrl, USER, USER, "clientid", "development");
        _local = new AMQConnection(_brokerUrl, USER, USER, "clientid", "localhost");

        _test.start();
        _dev.start();
        _local.start();
View Full Code Here

    protected void createConnection()
    {
        try
        {
            _connection = new AMQConnection(_brokerDetails, _username, _password, "PersistentTest", _virtualpath);

            _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

            _connection.start();
        }
View Full Code Here

                {
                    System.out.println("Continuing....");
                }

                //Test queue is still there.
                AMQConnection connection = new AMQConnection(_brokerDetails, _username, _password, "DifferentClientID", _virtualpath);

                AMQSession session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                try
                {
                    session.createConsumer(session.createQueue(QUEUE));
                    _logger.error("Create consumer succeeded." +
                                  " This shouldn't be allowed as this means the queue didn't exist when it should");

                    connection.close();

                    exit();
                }
                catch (JMSException e)
                {
                    try
                    {
                        connection.close();
                    }
                    catch (JMSException cce)
                    {
                        if (cce.getLinkedException() instanceof AMQConnectionClosedException)
                        {
View Full Code Here

        init(autoAcknowledge, true);

        String text = MessageFormat.format(TEST_MESSAGE_FORMAT, 0);
        Message message = _producerSession.createTextMessage(text);

        AMQConnection connection = (AMQConnection)_connection;

        // holding failover mutex should prevent the failover from
        // proceeding before we try to send the message
        synchronized(connection.getFailoverMutex())
        {
            failBroker(getFailingPort());

            // wait to make sure that connection is lost
            while(!connection.isFailingOver())
            {
                Thread.sleep(25l);
            }

            try
View Full Code Here

     */
    public void testFailoverHandlerTimeoutExpires() throws Exception
    {
        _connection.close();
        setTestSystemProperty("qpid.failover_method_timeout", "10000");
        AMQConnection connection = null;
        try
        {
            connection = createConnectionWithFailover();

            // holding failover mutex should prevent the failover from proceeding
            synchronized(connection.getFailoverMutex())
            {
                killBroker();
                startBroker();

                // sleep interval exceeds failover timeout interval
                Thread.sleep(11000l);
            }

            // allows the failover thread to proceed
            Thread.yield();
            assertFalse("Unexpected failover", _failoverComplete.await(2000l, TimeUnit.MILLISECONDS));
            assertTrue("Failover should not succeed due to timeout", connection.isClosed());
        }
        finally
        {
            if (connection != null)
            {
                connection.close();
            }
        }
    }
View Full Code Here

    public void testFailoverHandlerTimeoutReconnected() throws Exception
    {
        _connection.close();
        setTestSystemProperty("qpid.failover_method_timeout", "10000");
        AMQConnection connection = null;
        try
        {
            connection = createConnectionWithFailover();

            // holding failover mutex should prevent the failover from proceeding
            synchronized(connection.getFailoverMutex())
            {
                killBroker();
                startBroker();
            }

            // allows the failover thread to proceed
            Thread.yield();
            awaitForFailoverCompletion(DEFAULT_FAILOVER_TIME);
            assertFalse("Failover should restore connectivity", connection.isClosed());
        }
        finally
        {
            if (connection != null)
            {
                connection.close();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.client.AMQConnection

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.