Package org.apache.qpid.server

Examples of org.apache.qpid.server.AMQChannel


    public void methodReceived(AMQStateManager stateManager, AMQMethodEvent<BasicCancelBody> evt) throws AMQException
    {
        AMQProtocolSession protocolSession = stateManager.getProtocolSession();

        final AMQChannel channel = protocolSession.getChannel(evt.getChannelId());
        final BasicCancelBody body = evt.getMethod();

        if (channel == null)
        {
            throw body.getChannelNotFoundException(evt.getChannelId());
        }

        if (_log.isDebugEnabled())
        {
            _log.debug("BasicCancel: for:" + body.consumerTag +
                       " nowait:" + body.nowait);
        }

        channel.unsubscribeConsumer(protocolSession, body.consumerTag);
        if (!body.nowait)
        {
            // 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


//                          ": Requeue:" + evt.getMethod().requeue +
////                              ": Resend:" + evt.getMethod().resend +
//                          " on channel:" + channelId);
//        }

        AMQChannel channel = session.getChannel(channelId);

        if (channel == null)
        {
            throw evt.getMethod().getChannelNotFoundException(channelId);
        }

        if (_logger.isDebugEnabled())
        {
            _logger.debug("Rejecting:" + evt.getMethod().deliveryTag +
                          ": Requeue:" + evt.getMethod().requeue +
                          //": Resend:" + evt.getMethod().resend +
                          " on channel:" + channel.debugIdentity());
        }

        long deliveryTag = evt.getMethod().deliveryTag;

        UnacknowledgedMessage message = channel.getUnacknowledgedMessageMap().get(deliveryTag);

        if (message == null)
        {
            _logger.warn("Dropping reject request as message is null for tag:" + deliveryTag);
//            throw evt.getMethod().getChannelException(AMQConstant.NOT_FOUND, "Delivery Tag(" + deliveryTag + ")not known");
        }
        else
        {
            if (message.queue == null || message.queue.isDeleted())
            {
                _logger.warn("Message's Queue as already been purged, unable to Reject. " +
                             "Dropping message should use Dead Letter Queue");
                //sendtoDeadLetterQueue(msg)               
                return;
            }

            if (!message.message.isReferenced())
            {
                _logger.warn("Message as already been purged, unable to Reject.");
                return;
            }


            if (_logger.isTraceEnabled())
            {
                _logger.trace("Rejecting: DT:" + deliveryTag + "-" + message.message.debugIdentity() +
                              ": Requeue:" + evt.getMethod().requeue +
                              //": Resend:" + evt.getMethod().resend +
                              " on channel:" + channel.debugIdentity());
            }

            // If we haven't requested message to be resent to this consumer then reject it from ever getting it.
            //if (!evt.getMethod().resend)
            {
                message.message.reject(message.message.getDeliveredSubscription(message.queue));
            }

            if (evt.getMethod().requeue)
            {
                channel.requeue(deliveryTag);
            }
            else
            {
                _logger.warn("Dropping message as requeue not required and there is no dead letter queue");
                //sendtoDeadLetterQueue(AMQMessage message)
View Full Code Here

    public void methodReceived(AMQStateManager stateManager, AMQMethodEvent<ChannelFlowBody> evt) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();
        ChannelFlowBody body = evt.getMethod();

        AMQChannel channel = session.getChannel(evt.getChannelId());

        if (channel == null)
        {
            throw body.getChannelNotFoundException(evt.getChannelId());
        }

        channel.setSuspended(!body.active);
        _logger.debug("Channel.Flow for channel " + evt.getChannelId() + ", active=" + body.active);

        // 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

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

        AMQChannel channel = session.getChannel(evt.getChannelId());

        if (channel == null)
        {
            throw evt.getMethod().getChannelNotFoundException(evt.getChannelId());
        }

        channel.setLocalTransactional();

        // 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.
        session.writeFrame(TxSelectOkBody.createAMQFrame(evt.getChannelId(), (byte) 8, (byte) 0));
View Full Code Here

        {
            if (_log.isDebugEnabled())
            {
                _log.debug("Commit received on channel " + evt.getChannelId());
            }
            AMQChannel channel = session.getChannel(evt.getChannelId());

            if (channel == null)
            {
                throw evt.getMethod().getChannelNotFoundException(evt.getChannelId());
            }

            channel.commit();
            // 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.
            session.writeFrame(TxCommitOkBody.createAMQFrame(evt.getChannelId(), (byte) 8, (byte) 0));
            channel.processReturns(session);
        }
        catch (AMQException e)
        {
            throw evt.getMethod().getChannelException(e.getErrorCode(), "Failed to commit: " + e.getMessage());
        }
View Full Code Here

        BasicGetBody body = evt.getMethod();
        final int channelId = evt.getChannelId();
        VirtualHost vHost = session.getVirtualHost();

        AMQChannel channel = session.getChannel(channelId);
        if (channel == null)
        {
            throw body.getChannelNotFoundException(evt.getChannelId());
        }
        else
        {
            AMQQueue queue = body.queue == null ? channel.getDefaultQueue() : vHost.getQueueRegistry().getQueue(body.queue);

            if (queue == null)
            {
                _log.info("No queue for '" + body.queue + "'");
                if(body.queue!=null)
View Full Code Here

        final QueueBindBody body = evt.getMethod();
        final AMQQueue queue;
        if (body.queue == null)
        {
            AMQChannel channel = session.getChannel(evt.getChannelId());

            if (channel == null)
            {
                throw body.getChannelNotFoundException(evt.getChannelId());
            }

            queue = channel.getDefaultQueue();

            if (queue == null)
            {
                throw body.getChannelException(AMQConstant.NOT_FOUND, "No default queue defined on channel and queue was null");
            }
View Full Code Here

    {
        AMQProtocolSession session = stateManager.getProtocolSession();
        VirtualHost virtualHost = session.getVirtualHost();
        QueueRegistry queueRegistry = virtualHost.getQueueRegistry();

        AMQChannel channel = session.getChannel(evt.getChannelId());

        QueuePurgeBody body = evt.getMethod();
        AMQQueue queue;
        if(body.queue == null)
        {

           if (channel == null)
           {
               throw body.getChannelNotFoundException(evt.getChannelId());
           }

           //get the default queue on the channel:
           queue = channel.getDefaultQueue();
           
            if(queue == null)
            {
                if(_failIfNotFound)
                {
                    throw body.getConnectionException(AMQConstant.NOT_ALLOWED,"No queue specified.");
                }
            }
        }
        else
        {
            queue = queueRegistry.getQueue(body.queue);
        }

        if(queue == null)
        {
            if(_failIfNotFound)
            {
                throw body.getChannelException(AMQConstant.NOT_FOUND, "Queue " + body.queue + " does not exist.");
            }
        }
        else
        {
                long purged = queue.clearQueue(channel.getStoreContext());


                if(!body.nowait)
                {
                    // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
View Full Code Here

        assertTrue(_queue.getActiveConsumerCount() == 0);
        assertTrue(_queueMBean.getActiveConsumerCount() == 0);


        InternalTestProtocolSession protocolSession = new InternalTestProtocolSession();
        AMQChannel channel = new AMQChannel(protocolSession, 1, _messageStore);
        protocolSession.addChannel(channel);

        Subscription subscription =
                SUBSCRIPTION_FACTORY.createSubscription(channel.getChannelId(), protocolSession, new AMQShortString("test"), false, null, false, channel.getCreditManager());
       
        _queue.registerSubscription(subscription, false);
        assertEquals(1,(int)_queueMBean.getActiveConsumerCount());


        SubscriptionFactory subscriptionFactory = SUBSCRIPTION_FACTORY;
        Subscription s1 = subscriptionFactory.createSubscription(channel.getChannelId(),
                                                                 protocolSession,
                                                                 new AMQShortString("S1"),
                                                                 false,
                                                                 null,
                                                                 true,
                channel.getCreditManager());

        Subscription s2 = subscriptionFactory.createSubscription(channel.getChannelId(),
                                                                 protocolSession,
                                                                 new AMQShortString("S2"),
                                                                 false,
                                                                 null,
                                                                 true,
                channel.getCreditManager());
        _queue.registerSubscription(s1,false);
        _queue.registerSubscription(s2,false);
        assertTrue(_queueMBean.getActiveConsumerCount() == 3);
        assertTrue(_queueMBean.getConsumerCount() == 3);
View Full Code Here

     */
    public void commitTransactions(int channelId) throws JMException
    {
        try
        {
            AMQChannel channel = _session.getChannel(channelId);
            if (channel == null)
            {
                throw new JMException("The channel (channel Id = " + channelId + ") does not exist");
            }

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.