Examples of AMQChannel


Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

    public void methodReceived(AMQStateManager stateManager, QueuePurgeBody body, int channelId) throws AMQException
    {
        AMQProtocolSession protocolConnection = stateManager.getProtocolSession();
        VirtualHost virtualHost = protocolConnection.getVirtualHost();

        AMQChannel channel = protocolConnection.getChannel(channelId);
        if (channel == null)
        {
            throw body.getChannelNotFoundException(channelId);
        }
        AMQQueue queue;
        if(body.getQueue() == null)
        {

           //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 = virtualHost.getQueue(body.getQueue().toString());
        }

        if(queue == null)
        {
            if(_failIfNotFound)
            {
                throw body.getChannelException(AMQConstant.NOT_FOUND, "Queue " + body.getQueue() + " does not exist.");
            }
        }
        else
        {
                AMQSessionModel session = queue.getExclusiveOwningSession();

                if (queue.isExclusive() && (session == null || session.getConnectionModel() != protocolConnection))
                {
                    throw body.getConnectionException(AMQConstant.NOT_ALLOWED,
                                                      "Queue is exclusive, but not created on this Connection.");
                }

                long purged = queue.clearQueue();


                if(!body.getNowait())
                {
                    channel.sync();
                    MethodRegistry methodRegistry = protocolConnection.getMethodRegistry();
                    AMQMethodBody responseBody = methodRegistry.createQueuePurgeOkBody(purged);
                    protocolConnection.writeFrame(responseBody.generateFrame(channelId));

                }
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

    }

    public void methodReceived(AMQStateManager stateManager, AccessRequestBody body, int channelId) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();
        final AMQChannel channel = session.getChannel(channelId);
        if (channel == null)
        {
            throw body.getChannelNotFoundException(channelId);
        }

        MethodRegistry methodRegistry = session.getMethodRegistry();

        // We don't implement access control class, but to keep clients happy that expect it
        // always use the "0" ticket.
        AccessRequestOkBody response;
        if(methodRegistry instanceof MethodRegistry_0_9)
        {
            response = ((MethodRegistry_0_9)methodRegistry).createAccessRequestOkBody(0);
        }
        else if(methodRegistry instanceof MethodRegistry_8_0)
        {
            response = ((MethodRegistry_8_0)methodRegistry).createAccessRequestOkBody(0);
        }
        else
        {
            throw new AMQException(AMQConstant.COMMAND_INVALID, "AccessRequest not present in AMQP versions other than 0-8, 0-9");
        }

        channel.sync();
        session.writeFrame(response.generateFrame(channelId));
    }
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

    public void methodReceived(AMQStateManager stateManager, ExchangeDeleteBody body, int channelId) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();
        VirtualHost virtualHost = session.getVirtualHost();
        final AMQChannel channel = session.getChannel(channelId);
        if (channel == null)
        {
            throw body.getChannelNotFoundException(channelId);
        }
        channel.sync();
        try
        {
            final String exchangeName = body.getExchange() == null ? null : body.getExchange().toString();

            final Exchange exchange = virtualHost.getExchange(exchangeName);
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

    public void methodReceived(AMQStateManager stateManager, BasicRecoverSyncBody body, int channelId) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();

        _logger.debug("Recover received on protocol session " + session + " and channel " + channelId);
        AMQChannel channel = session.getChannel(channelId);


        if (channel == null)
        {
            throw body.getChannelNotFoundException(channelId);
        }
        channel.sync();
        channel.resend(body.getRequeue());

        // Qpid 0-8 hacks a synchronous -ok onto recover.
        // In Qpid 0-9 we create a separate sync-recover, sync-recover-ok pair to be "more" compliant
        if(session.getProtocolVersion().equals(ProtocolVersion.v0_9))
        {
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

    public void methodReceived(AMQStateManager stateManager, BasicRejectBody body, int channelId) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();

        AMQChannel channel = session.getChannel(channelId);

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

        if (_logger.isDebugEnabled())
        {
            _logger.debug("Rejecting:" + body.getDeliveryTag() +
                          ": Requeue:" + body.getRequeue() +
                          " on channel:" + channel.debugIdentity());
        }

        long deliveryTag = body.getDeliveryTag();

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

        if (message == null)
        {
            _logger.warn("Dropping reject request as message is null for tag:" + deliveryTag);
        }
        else
        {
            if (message.isQueueDeleted())
            {
                _logger.warn("Message's Queue has already been purged, dropping message");
                message = channel.getUnacknowledgedMessageMap().remove(deliveryTag);
                if(message != null)
                {
                    message.discard();
                }
                return;
            }

            if (message.getMessage() == null)
            {
                _logger.warn("Message has already been purged, unable to Reject.");
                return;
            }


            if (_logger.isDebugEnabled())
            {
                _logger.debug("Rejecting: DT:" + deliveryTag + "-" + message.getMessage() +
                              ": Requeue:" + body.getRequeue() +
                              " on channel:" + channel.debugIdentity());
            }

            message.reject();

            if (body.getRequeue())
            {
                channel.requeue(deliveryTag);

                //this requeue represents a message rejected from the pre-dispatch queue
                //therefore we need to amend the delivery counter.
                message.decrementDeliveryCount();
            }
            else
            {
                 final boolean maxDeliveryCountEnabled = channel.isMaxDeliveryCountEnabled(deliveryTag);
                 _logger.debug("maxDeliveryCountEnabled: " + maxDeliveryCountEnabled + " deliveryTag " + deliveryTag);
                 if (maxDeliveryCountEnabled)
                 {
                     final boolean deliveredTooManyTimes = channel.isDeliveredTooManyTimes(deliveryTag);
                     _logger.debug("deliveredTooManyTimes: " + deliveredTooManyTimes + " deliveryTag " + deliveryTag);
                     if (deliveredTooManyTimes)
                     {
                         channel.deadLetter(body.getDeliveryTag());
                     }
                     else
                     {
                         //this requeue represents a message rejected because of a recover/rollback that we
                         //are not ready to DLQ. We rely on the reject command to resend from the unacked map
                         //and therefore need to increment the delivery counter so we cancel out the effect
                         //of the AMQChannel#resend() decrement.
                         message.incrementDeliveryCount();
                     }
                 }
                 else
                 {
                     channel.deadLetter(body.getDeliveryTag());
                 }
            }
        }
    }
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

    public void methodReceived(AMQStateManager stateManager, ChannelFlowBody body, int channelId) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();


        AMQChannel channel = session.getChannel(channelId);

        if (channel == null)
        {
            throw body.getChannelNotFoundException(channelId);
        }
        channel.sync();
        channel.setSuspended(!body.getActive());
        _logger.debug("Channel.Flow for channel " + channelId + ", active=" + body.getActive());

        MethodRegistry methodRegistry = session.getMethodRegistry();
        AMQMethodBody responseBody = methodRegistry.createChannelFlowOkBody(body.getActive());
        session.writeFrame(responseBody.generateFrame(channelId));
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

    public void methodReceived(AMQStateManager stateManager, TxSelectBody body, int channelId) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();

        AMQChannel channel = session.getChannel(channelId);

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

        channel.setLocalTransactional();

        MethodRegistry methodRegistry = session.getMethodRegistry();
        TxSelectOkBody responseBody = methodRegistry.createTxSelectOkBody();
        session.writeFrame(responseBody.generateFrame(channelId));
    }
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

        {
            throw new AMQException(AMQConstant.COMMAND_INVALID, "Virtualhost has not yet been set. ConnectionOpen has not been called.", null);
        }
        _logger.info("Connecting to: " + virtualHost.getName());

        final AMQChannel channel = new AMQChannel(session,channelId, virtualHost.getMessageStore());

        session.addChannel(channel);

        ChannelOpenOkBody response;
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

        if (_log.isDebugEnabled())
        {
            _log.debug("Ack(Tag:" + body.getDeliveryTag() + ":Mult:" + body.getMultiple() + ") received on channel " + channelId);
        }

        final AMQChannel channel = protocolSession.getChannel(channelId);

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

        // this method throws an AMQException if the delivery tag is not known
        channel.acknowledgeMessage(body.getDeliveryTag(), body.getMultiple());
    }
View Full Code Here

Examples of org.apache.qpid.server.protocol.v0_8.AMQChannel

            _logger.info("Received channel close for id " + channelId + " citing class " + body.getClassId() +
                         " and method " + body.getMethodId());
        }


        AMQChannel channel = session.getChannel(channelId);

        if (channel == null)
        {
            throw body.getConnectionException(AMQConstant.CHANNEL_ERROR, "Trying to close unknown channel");
        }
        channel.sync();
        session.closeChannel(channelId);
        // Client requested closure so we don't wait for ok we send it
        stateManager.getProtocolSession().closeChannelOk(channelId);

        MethodRegistry methodRegistry = session.getMethodRegistry();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.