Package org.apache.qpid.management.common.mbeans

Examples of org.apache.qpid.management.common.mbeans.ManagedConnection


        //Remove the connection close from any 0-10 connections
        _monitor.markDiscardPoint();

        // Get a managedConnection
        ManagedConnection mangedConnection = _jmxUtils.getManagedObject(ManagedConnection.class, "org.apache.qpid:type=VirtualHost.Connection,*");

        //Close the connection
        mangedConnection.closeConnection();

        //Wait for the connection to close
        assertTrue("Timed out waiting for conneciton to report close",
                   exceptionReceived.await(2, TimeUnit.SECONDS));

View Full Code Here


        }

        List<ManagedConnection> connections = _jmxUtils.getManagedConnections("test");
        assertNotNull("Connection MBean is not found", connections);
        assertEquals("Unexpected number of connection mbeans", 1, connections.size());
        final ManagedConnection mBean = connections.get(0);
        assertNotNull("Connection MBean is null", mBean);

        TabularData channelsData = mBean.channels();
        assertNotNull("Channels data are null", channelsData);
        assertEquals("Unexpected number of rows in channel table", 1, channelsData.size());

        final Iterator<CompositeDataSupport> rowItr = (Iterator<CompositeDataSupport>) channelsData.values().iterator();
        final CompositeDataSupport row = rowItr.next();
        Number unackCount = (Number) row.get(ManagedConnection.UNACKED_COUNT);
        final Boolean transactional = (Boolean) row.get(ManagedConnection.TRANSACTIONAL);
        final Boolean flowBlocked = (Boolean) row.get(ManagedConnection.FLOW_BLOCKED);
        assertNotNull("Channel should have unacknowledged messages", unackCount);
        assertEquals("Unexpected number of unacknowledged messages", 2, unackCount.intValue());
        assertNotNull("Channel should have transaction flag", transactional);
        assertTrue("Unexpected transaction flag", transactional);
        assertNotNull("Channel should have flow blocked flag", flowBlocked);
        assertFalse("Unexpected value of flow blocked flag", flowBlocked);

        final Date initialLastIOTime = mBean.getLastIoTime();
        session.commit();
        assertTrue("Last IO time should have been updated", mBean.getLastIoTime().after(initialLastIOTime));

        channelsData = mBean.channels();
        assertNotNull("Channels data are null", channelsData);
        assertEquals("Unexpected number of rows in channel table", 1, channelsData.size());

        final Iterator<CompositeDataSupport> rowItr2 = (Iterator<CompositeDataSupport>) channelsData.values().iterator();
        final CompositeDataSupport row2 = rowItr2.next();
View Full Code Here

        _connection.start();

        List<ManagedConnection> connections = _jmxUtils.getManagedConnections("test");
        assertNotNull("Connection MBean is not found", connections);
        assertEquals("Unexpected number of connection mbeans", 1, connections.size());
        final ManagedConnection mBean = connections.get(0);
        assertNotNull("Connection MBean is null", mBean);

        final int numberOfMessages = 2;
        for (int i = 0; i < numberOfMessages; i++)
        {
            producer.send(producerSession.createTextMessage("Test " + i));
        }

        // sync to make sure that messages are received on the broker
        // before we commit via JMX
        ((AMQSession<?, ?>) producerSession).sync();

        Message m = consumer.receive(500l);
        assertNull("Unexpected message received", m);

        Number channelId = getFirstTransactedChannelId(mBean, 2);
        mBean.commitTransactions(channelId.intValue());

        for (int i = 0; i < numberOfMessages; i++)
        {
            m = consumer.receive(1000l);
            assertNotNull("Message " + i + " is not received", m);
View Full Code Here

        final MessageProducer producer = producerSession.createProducer(destination);

        List<ManagedConnection> connections = _jmxUtils.getManagedConnections("test");
        assertNotNull("Connection MBean is not found", connections);
        assertEquals("Unexpected number of connection mbeans", 1, connections.size());
        final ManagedConnection mBean = connections.get(0);
        assertNotNull("Connection MBean is null", mBean);

        final int numberOfMessages = 2;
        for (int i = 0; i < numberOfMessages; i++)
        {
            producer.send(producerSession.createTextMessage("Test " + i));
        }

        // sync to make sure that messages are received on the broker
        // before we rollback via JMX
        ((AMQSession<?, ?>) producerSession).sync();

        Number channelId = getFirstTransactedChannelId(mBean, 2);
        mBean.rollbackTransactions(channelId.intValue());

        Message m = consumer.receive(1000l);
        assertNull("Unexpected message received: " + String.valueOf(m), m);

        producerSession.commit();
View Full Code Here

    public void testAuthorisedId() throws Exception
    {
        List<ManagedConnection> connections = _jmxUtils.getManagedConnections("test");
        assertNotNull("Connection MBean is not found", connections);
        assertEquals("Unexpected number of connection mbeans", 1, connections.size());
        final ManagedConnection mBean = connections.get(0);
        assertNotNull("Connection MBean is null", mBean);
        assertEquals("Unexpected authorized id", "guest", mBean.getAuthorizedId());
    }
View Full Code Here

    public void testClientVersion() throws Exception
    {
        List<ManagedConnection> connections = _jmxUtils.getManagedConnections("test");
        assertNotNull("Connection MBean is not found", connections);
        assertEquals("Unexpected number of connection mbeans", 1, connections.size());
        final ManagedConnection mBean = connections.get(0);
        assertNotNull("Connection MBean is null", mBean);

        String expectedVersion = QpidProperties.getReleaseVersion();
        assertNotNull("version should not be null", expectedVersion);
        assertFalse("version should not be the empty string", expectedVersion.equals(""));
        assertFalse("version should not be the string 'null'", expectedVersion.equals("null"));

        assertEquals("Unexpected version", expectedVersion, mBean.getVersion());
    }
View Full Code Here

    public void testClientId() throws Exception
    {
        List<ManagedConnection> connections = _jmxUtils.getManagedConnections("test");
        assertNotNull("Connection MBean is not found", connections);
        assertEquals("Unexpected number of connection mbeans", 1, connections.size());
        final ManagedConnection mBean = connections.get(0);
        assertNotNull("Connection MBean is null", mBean);

        String expectedClientId = _connection.getClientID();
        assertNotNull("ClientId should not be null", expectedClientId);
        assertFalse("ClientId should not be the empty string", expectedClientId.equals(""));
        assertFalse("ClientId should not be the string 'null'", expectedClientId.equals("null"));

        assertEquals("Unexpected ClientId", expectedClientId, mBean.getClientId());
    }
View Full Code Here

    }

    public void testGetAttributes() throws Exception
    {
        _connection = getConnection();
        final ManagedConnection mBean = getConnectionMBean();

        checkAuthorisedId(mBean);
        checkClientVersion(mBean);
        checkClientId(mBean);
    }
View Full Code Here

        boolean transactional = false;
        boolean flowBlocked = false;

        _connection.createSession(transactional, Session.AUTO_ACKNOWLEDGE);

        final ManagedConnection mBean = getConnectionMBean();
        final CompositeDataSupport row = getTheOneChannelRow(mBean);
        assertChannelRowData(row, 0, transactional, flowBlocked);
    }
View Full Code Here

        final MessageConsumer consumer = session.createConsumer(destination);

        sendMessage(session, destination, numberOfMessages);
        receiveMessagesWithoutCommit(consumer, numberOfMessages);

        final ManagedConnection mBean = getConnectionMBean();
        final CompositeDataSupport row = getTheOneChannelRow(mBean);
        boolean flowBlocked = false;
        assertChannelRowData(row, numberOfMessages, transactional, flowBlocked);

        // check that commit advances the lastIoTime
        final Date initialLastIOTime = mBean.getLastIoTime();
        session.commit();
        assertTrue("commit should have caused last IO time to advance", mBean.getLastIoTime().after(initialLastIOTime));

        // check that channels() now returns one session with no unacknowledged messages
        final CompositeDataSupport rowAfterCommit = getTheOneChannelRow(mBean);
        final Number unackCountAfterCommit = (Number) rowAfterCommit.get(ManagedConnection.UNACKED_COUNT);
        assertEquals("Unexpected number of unacknowledged messages", 0, unackCountAfterCommit);
View Full Code Here

TOP

Related Classes of org.apache.qpid.management.common.mbeans.ManagedConnection

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.