Package org.apache.qpid.framing

Examples of org.apache.qpid.framing.BasicConsumeBody


        if (consumer.isNoConsume())
        {
            arguments.put(AMQPFilterTypes.NO_CONSUME.getValue(), Boolean.TRUE);
        }

        BasicConsumeBody body = getMethodRegistry().createBasicConsumeBody(getTicket(),
                                                                           queueName,
                                                                           new AMQShortString(String.valueOf(tag)),
                                                                           consumer.isNoLocal(),
                                                                           consumer.getAcknowledgeMode() == Session.NO_ACKNOWLEDGE,
                                                                           consumer.isExclusive(),
                                                                           nowait,
                                                                           arguments);


        AMQFrame jmsConsume = body.generateFrame(_channelId);

        if (nowait)
        {
            protocolHandler.writeFrame(jmsConsume);
        }
View Full Code Here


    {
        for(AMQShortString queue : _counts.keySet())
        {
            // 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.
            BasicConsumeBody m = new BasicConsumeBody((byte)8,
                                                      (byte)0,
                                                      BasicConsumeBody.getClazz((byte)8, (byte)0),
                                                      BasicConsumeBody.getMethod((byte)8, (byte)0),
                                                      null,
                                                      queue,
View Full Code Here

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

        BasicConsumeBody body = evt.getMethod();
        final int channelId = evt.getChannelId();

        AMQChannel channel = session.getChannel(channelId);

        VirtualHost vHost = session.getVirtualHost();

        if (channel == null)
        {
            throw body.getChannelNotFoundException(evt.getChannelId());
        }
        else
        {
            if (_log.isDebugEnabled())
            {
                _log.debug("BasicConsume: from '" + body.queue +
                           "' for:" + body.consumerTag +
                           " nowait:" + body.nowait +
                           " args:" + body.arguments);
            }

            AMQQueue queue = body.queue == null ? channel.getDefaultQueue() : vHost.getQueueRegistry().getQueue(body.queue);

            if (queue == null)
            {
                if (_log.isTraceEnabled())
                {
                    _log.trace("No queue for '" + body.queue + "'");
                }
                if (body.queue != null)
                {
                    String msg = "No such queue, '" + body.queue + "'";
                    throw body.getChannelException(AMQConstant.NOT_FOUND, msg);
                }
                else
                {
                    String msg = "No queue name provided, no default queue defined.";
                    throw body.getConnectionException(AMQConstant.NOT_ALLOWED, msg);
                }
            }
            else
            {

                if (body.consumerTag != null)
                {
                    body.consumerTag = body.consumerTag.intern();
                }

                try
                {
                    AMQShortString consumerTag = channel.subscribeToQueue(body.consumerTag, queue, session, !body.noAck,
                                                                          body.arguments, body.noLocal, body.exclusive);
                    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.
                        session.writeFrame(BasicConsumeOkBody.createAMQFrame(channelId,
                                                                             (byte) 8, (byte) 0,    // AMQP version (major, minor)
                                                                             consumerTag));        // consumerTag
                    }

                    //now allow queue to start async processing of any backlog of messages
                    queue.deliverAsync();
                }
                catch (org.apache.qpid.AMQInvalidArgumentException ise)
                {
                    _log.debug("Closing connection due to invalid selector");
                    // Why doesn't this ChannelException work.
//                    throw body.getChannelException(AMQConstant.INVALID_ARGUMENT, ise.getMessage());
                    // 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(ChannelCloseBody.createAMQFrame(channelId,
                                                                       (byte) 8, (byte) 0,    // AMQP version (major, minor)
                                                                       BasicConsumeBody.getClazz((byte) 8, (byte) 0),    // classId
                                                                       BasicConsumeBody.getMethod((byte) 8, (byte) 0),    // methodId
                                                                       AMQConstant.INVALID_ARGUMENT.getCode(),    // replyCode
                                                                       new AMQShortString(ise.getMessage())));        // replyText
                }
                catch (ConsumerTagNotUniqueException e)
                {
                    AMQShortString msg = new AMQShortString("Non-unique consumer tag, '" + body.consumerTag + "'");
                    // If the above doesn't work then perhaps this is wrong too.
//                    throw body.getConnectionException(AMQConstant.NOT_ALLOWED,
//                                                      "Non-unique consumer tag, '" + body.consumerTag + "'");
                    // 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(ConnectionCloseBody.createAMQFrame(channelId,
                                                                          (byte) 8, (byte) 0,    // AMQP version (major, minor)
                                                                          BasicConsumeBody.getClazz((byte) 8, (byte) 0),    // classId
                                                                          BasicConsumeBody.getMethod((byte) 8, (byte) 0),    // methodId
                                                                          AMQConstant.NOT_ALLOWED.getCode(),    // replyCode
                                                                          msg));    // replyText
                }
                catch (AMQQueue.ExistingExclusiveSubscription e)
                {
                    throw body.getChannelException(AMQConstant.ACCESS_REFUSED,
                                                   "Cannot subscribe to queue "
                                                   + queue.getName()
                                                   + " as it already has an existing exclusive consumer");
                }
                catch (AMQQueue.ExistingSubscriptionPreventsExclusive e)
                {
                    throw body.getChannelException(AMQConstant.ACCESS_REFUSED,
                                                   "Cannot subscribe to queue "
                                                   + queue.getName()
                                                   + " exclusively as it already has a consumer");
                }
View Full Code Here

        if (consumer.isNoConsume())
        {
            arguments.put(AMQPFilterTypes.NO_CONSUME.getValue(), Boolean.TRUE);
        }

        BasicConsumeBody body = getMethodRegistry().createBasicConsumeBody(getTicket(),
                                                                           queueName,
                                                                           new AMQShortString(String.valueOf(tag)),
                                                                           consumer.isNoLocal(),
                                                                           consumer.getAcknowledgeMode() == Session.NO_ACKNOWLEDGE,
                                                                           consumer.isExclusive(),
                                                                           nowait,
                                                                           arguments);


        AMQFrame jmsConsume = body.generateFrame(_channelId);

        if (nowait)
        {
            protocolHandler.writeFrame(jmsConsume);
        }
View Full Code Here

    public void methodReceived(AMQStateManager stateManager, QueueRegistry queueRegistry,
                               ExchangeRegistry exchangeRegistry, AMQProtocolSession session,
                               AMQMethodEvent<BasicConsumeBody> evt) throws AMQException
    {
        BasicConsumeBody body = evt.getMethod();
        final int channelId = evt.getChannelId();

        AMQChannel channel = session.getChannel(channelId);
        if (channel == null)
        {
View Full Code Here

    synchronized void replay(List<AMQMethodBody> messages)
    {
        for(String queue : _counts.keySet())
        {
            BasicConsumeBody m = new BasicConsumeBody();
            m.queue = queue;
            m.consumerTag = queue;
            replay(m, messages);
        }
    }
View Full Code Here

        if (consumer.isNoConsume())
        {
            arguments.put(AMQPFilterTypes.NO_CONSUME.getValue(), Boolean.TRUE);
        }

        BasicConsumeBody body = getMethodRegistry().createBasicConsumeBody(getTicket(),
                                                                           queueName,
                                                                           new AMQShortString(String.valueOf(tag)),
                                                                           consumer.isNoLocal(),
                                                                           consumer.getAcknowledgeMode() == Session.NO_ACKNOWLEDGE,
                                                                           consumer.isExclusive(),
                                                                           nowait,
                                                                           arguments);


        AMQFrame jmsConsume = body.generateFrame(_channelId);

        if (nowait)
        {
            protocolHandler.writeFrame(jmsConsume);
        }
View Full Code Here

        if (consumer.isNoConsume())
        {
            arguments.put(AMQPFilterTypes.NO_CONSUME.getValue(), Boolean.TRUE);
        }

        BasicConsumeBody body = getMethodRegistry().createBasicConsumeBody(getTicket(),
                                                                           queueName,
                                                                           new AMQShortString(String.valueOf(tag)),
                                                                           consumer.isNoLocal(),
                                                                           consumer.getAcknowledgeMode() == Session.NO_ACKNOWLEDGE,
                                                                           consumer.isExclusive(),
                                                                           nowait,
                                                                           arguments);


        AMQFrame jmsConsume = body.generateFrame(_channelId);

        if (nowait)
        {
            protocolHandler.writeFrame(jmsConsume);
        }
View Full Code Here

TOP

Related Classes of org.apache.qpid.framing.BasicConsumeBody

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.