Package org.apache.qpid.server

Examples of org.apache.qpid.server.AMQChannel


     * @throws AMQException             if an error occurs closing the channel
     * @throws IllegalArgumentException if the channel id is not valid
     */
    public void closeChannel(int channelId) throws AMQException
    {
        final AMQChannel channel = getChannel(channelId);
        if (channel == null)
        {
            throw new IllegalArgumentException("Unknown channel id");
        }
        else
        {
            try
            {
                channel.close();
                markChannelAwaitingCloseOk(channelId);
            }
            finally
            {
                removeChannel(channelId);
View Full Code Here


        AMQQueue queue = new org.apache.qpid.server.queue.AMQQueue(new AMQShortString("testQueue_" + System.currentTimeMillis()),
                                                                   false,
                                                                   new AMQShortString("test"),
                                                                   true,
                                                                   _protocolSession.getVirtualHost());
        AMQChannel channel = new AMQChannel(_protocolSession,2, _messageStore, null);
        channel.setDefaultQueue(queue);
        _protocolSession.addChannel(channel);
        channelCount = _mbean.channels().size();
        assertTrue(channelCount == 2);

        // general properties test
        _mbean.setMaximumNumberOfChannels(1000L);
        assertTrue(_mbean.getMaximumNumberOfChannels() == 1000L);

        // check APIs
        AMQChannel channel3 = new AMQChannel(_protocolSession,3, _messageStore, null);
        channel3.setLocalTransactional();
        _protocolSession.addChannel(channel3);
        _mbean.rollbackTransactions(2);
        _mbean.rollbackTransactions(3);
        _mbean.commitTransactions(2);
        _mbean.commitTransactions(3);

        // This should throw exception, because the channel does't exist
        try
        {
            _mbean.commitTransactions(4);
            fail();
        }
        catch (JMException ex)
        {
            System.out.println("expected exception is thrown :" + ex.getMessage());    
        }

        // check if closing of session works
        _protocolSession.addChannel(new AMQChannel(_protocolSession,5, _messageStore, null));
        _mbean.closeConnection();
        try
        {
            channelCount = _mbean.channels().size();
            assertTrue(channelCount == 0);
            // session is now closed so adding another channel should throw an exception
            _protocolSession.addChannel(new AMQChannel(_protocolSession,6, _messageStore, null));
            fail();
        }
        catch(AMQException ex)
        {
            System.out.println("expected exception is thrown :" + ex.getMessage());
View Full Code Here

        _protocolSession = new AMQMinaProtocolSession(new MockIoSession(),
                                                      appRegistry.getVirtualHostRegistry(),
                                                      new AMQCodecFactory(true),
                                                      null);
        _protocolSession.setVirtualHost(appRegistry.getVirtualHostRegistry().getVirtualHost("test"));
        _channel = new AMQChannel(_protocolSession,1, _messageStore, null);
        _protocolSession.addChannel(_channel);
        _mbean = (AMQProtocolSessionMBean)_protocolSession.getManagedObject();
    }
View Full Code Here

    }

    public AMQChannel getChannel(int channelId)
        throws AMQException
    {
        AMQChannel channel = super.getChannel(channelId);
        if (isPeerSession() && channel == null)
        {
            channel = new OneUseChannel(channelId, getVirtualHost());
            addChannel(channel);
        }
View Full Code Here

    }

    private void contentHeaderReceived(int channelId, ContentHeaderBody body) throws AMQException
    {

        AMQChannel channel = getAndAssertChannel(channelId);

        channel.publishContentHeader(body, this);

    }
View Full Code Here

    }

    private void contentBodyReceived(int channelId, ContentBody body) throws AMQException
    {
        AMQChannel channel = getAndAssertChannel(channelId);

        channel.publishContentBody(body, this);
    }
View Full Code Here

        return new ArrayList<AMQChannel>(_channelMap.values());
    }

    public AMQChannel getAndAssertChannel(int channelId) throws AMQException
    {
        AMQChannel channel = getChannel(channelId);
        if (channel == null)
        {
            throw new AMQException(AMQConstant.NOT_FOUND, "Channel not found with id:" + channelId);
        }
View Full Code Here

        return channel;
    }

    public AMQChannel getChannel(int channelId) throws AMQException
    {
        final AMQChannel channel =
            ((channelId & CHANNEL_CACHE_SIZE) == channelId) ? _cachedChannels[channelId] : _channelMap.get(channelId);
        if ((channel == null) || channel.isClosing())
        {
            return null;
        }
        else
        {
View Full Code Here

     * @throws AMQException             if an error occurs closing the channel
     * @throws IllegalArgumentException if the channel id is not valid
     */
    public void closeChannel(int channelId) throws AMQException
    {
        final AMQChannel channel = getChannel(channelId);
        if (channel == null)
        {
            throw new IllegalArgumentException("Unknown channel id");
        }
        else
        {
            try
            {
                channel.close(this);
                markChannelawaitingCloseOk(channelId);
            }
            finally
            {
                removeChannel(channelId);
View Full Code Here

    public void methodReceived(AMQStateManager stateManager, AMQMethodEvent<ChannelOpenBody> evt) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();
        VirtualHost virtualHost = session.getVirtualHost();

        final AMQChannel channel = new AMQChannel(session,evt.getChannelId(), virtualHost.getMessageStore(),
                                                  virtualHost.getExchangeRegistry());
        session.addChannel(channel);
        // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
        // TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
        // Be aware of possible changes to parameter order as versions change.
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.AMQChannel

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.