Package org.apache.qpid.server.protocol

Examples of org.apache.qpid.server.protocol.AMQProtocolSession


        _localRecorders.put(ExchangeDeleteBody.class, new ExchangeDeleteRecorder());
    }

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

        _logger.debug(new LogMessage("Replay store received {0}", evt.getMethod()));
        AMQMethodBody request = evt.getMethod();

        //allow any (relevant) recorder registered for this type of request to record it:
View Full Code Here


{
    private final Logger _logger = Logger.getLogger(RemoteConsumeHandler.class);

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

        AMQQueue queue = queueRegistry.getQueue(evt.getMethod().queue);
        if (queue instanceof ClusteredQueue)
        {
            ((ClusteredQueue) queue).addRemoteSubcriber(ClusteredProtocolSession.getSessionPeer(session));
            // 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(evt.getChannelId(),
              (byte)8, (byte)0// AMQP version (major, minor)
              evt.getMethod().queue  // consumerTag
                ));
        }
        else
View Full Code Here

public abstract class ClusterMethodHandler<A extends AMQMethodBody> implements StateAwareMethodListener<A>
{
    public final void methodReceived(AMQStateManager stateMgr, AMQMethodEvent<A> evt) throws AMQException
    {
        AMQProtocolSession session = stateMgr.getProtocolSession();

        if (ClusteredProtocolSession.isPeerSession(session))
        {
            peer(stateMgr, evt);
        }
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.
        AMQFrame response = ChannelOpenOkBody.createAMQFrame(evt.getChannelId(), (byte)8, (byte)0);
        session.writeFrame(response);
    }
View Full Code Here

    {
    }

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

        if (_log.isDebugEnabled())
        {
            _log.debug("Ack(Tag:" + body.deliveryTag + ":Mult:" + body.multiple + ") received on channel " + evt.getChannelId());
        }

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

        if (channel == null)
        {
            throw body.getChannelNotFoundException(evt.getChannelId());
        }
View Full Code Here

    {
    }

    public void methodReceived(AMQStateManager stateManager, AMQMethodEvent<ChannelCloseBody> evt) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();
        ChannelCloseBody body = evt.getMethod();
        if (_logger.isInfoEnabled())
        {
            _logger.info("Received channel close for id " + evt.getChannelId() + " citing class " + body.classId +
                         " and method " + body.methodId);
        }
        int channelId = evt.getChannelId();

        AMQChannel channel = session.getChannel(channelId);

        if (channel == null)
        {
            throw body.getConnectionException(AMQConstant.CHANNEL_ERROR, "Trying to close unknown channel");
        }

        session.closeChannel(channelId);
        // Client requested closure so we don't wait for ok we send it
        stateManager.getProtocolSession().closeChannelOk(channelId);

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

                _logger.debug("Subscription:" + debugIdentity() + " rejected message:" + msg.debugIdentity());
            }
//            return false;
        }

        final AMQProtocolSession publisher = msg.getPublisher();

        //todo - client id should be recoreded and this test removed but handled below
        if (_noLocal && publisher != null)
        {
            // We don't want local messages so check to see if message is one we sent
            Object localInstance;
            Object msgInstance;

            if ((protocolSession.getClientProperties() != null) &&
                (localInstance = protocolSession.getClientProperties().getObject(CLIENT_PROPERTIES_INSTANCE)) != null)
            {

                if ((publisher.getClientProperties() != null) &&
                    (msgInstance = publisher.getClientProperties().getObject(CLIENT_PROPERTIES_INSTANCE)) != null)
                {
                    if (localInstance == msgInstance || localInstance.equals(msgInstance))
                    {
//                        if (_logger.isTraceEnabled())
//                        {
//                            _logger.trace("(" + debugIdentity() + ") has no interest as it is a local message(" +
//                                          msg.debugIdentity() + ")");
//                        }
                        return false;
                    }
                }
            }
            else
            {

                localInstance = protocolSession.getClientIdentifier();
                //todo - client id should be recoreded and this test removed but handled here

                msgInstance = publisher.getClientIdentifier();
                if (localInstance == msgInstance || ((localInstance != null) && localInstance.equals(msgInstance)))
                {
//                    if (_logger.isTraceEnabled())
//                    {
//                        _logger.trace("(" + debugIdentity() + ") has no interest as it is a local message(" +
View Full Code Here

    {
    }

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

        final BasicPublishBody body = evt.getMethod();

        if (_log.isDebugEnabled())
        {
            _log.debug("Publish received on channel " + evt.getChannelId());
        }

        // TODO: check the delivery tag field details - is it unique across the broker or per subscriber?
        if (body.exchange == null)
        {
            body.exchange = ExchangeDefaults.DEFAULT_EXCHANGE_NAME;

        }
        else
        {
            body.exchange = body.exchange.intern();
        }
        VirtualHost vHost = session.getVirtualHost();
        Exchange e = vHost.getExchangeRegistry().getExchange(body.exchange);
        // if the exchange does not exist we raise a channel exception
        if (e == null)
        {
            throw body.getChannelException(AMQConstant.NOT_FOUND, "Unknown exchange name");
        }
        else
        {
            // The partially populated BasicDeliver frame plus the received route body
            // is stored in the channel. Once the final body frame has been received
            // it is routed to the exchange.
            AMQChannel channel = session.getChannel(evt.getChannelId());

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

            if(body.routingKey != null)
            {
                body.routingKey = body.routingKey.intern();
            }
           
            MessagePublishInfo info = session.getRegistry().getProtocolVersionMethodConverter().convertToInfo(body);
            channel.setPublishFrame(info, session);
        }
    }
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
View Full Code Here

    {
    }

    public void methodReceived(AMQStateManager stateManager, AMQMethodEvent<ConnectionCloseOkBody> evt) throws AMQException
    {
        AMQProtocolSession session = stateManager.getProtocolSession();
        //todo should this not do more than just log the method?
        _logger.info("Received Connection-close-ok");

        try
        {
            stateManager.changeState(AMQState.CONNECTION_CLOSED);
            session.closeSession();
        }
        catch (Exception e)
        {
            _logger.error("Error closing protocol session: " + e, e);
        }
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.protocol.AMQProtocolSession

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.