Package org.apache.qpid.framing

Examples of org.apache.qpid.framing.QueueBindBody


        AMQProtocolSession session = stateManager.getProtocolSession();
        VirtualHost virtualHost = session.getVirtualHost();
        ExchangeRegistry exchangeRegistry = virtualHost.getExchangeRegistry();
        QueueRegistry queueRegistry = virtualHost.getQueueRegistry();

        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");
            }

            if (body.routingKey == null)
            {
                body.routingKey = queue.getName();
            }
        }
        else
        {
            queue = queueRegistry.getQueue(body.queue);
        }

        if (queue == null)
        {
            throw body.getChannelException(AMQConstant.NOT_FOUND, "Queue " + body.queue + " does not exist.");
        }
        final Exchange exch = exchangeRegistry.getExchange(body.exchange);
        if (exch == null)
        {
            throw body.getChannelException(AMQConstant.NOT_FOUND, "Exchange " + body.exchange + " does not exist.");
        }

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

        try
        {
            if (!exch.isBound(body.routingKey, body.arguments, queue))
            {
                queue.bind(body.routingKey, body.arguments, exch);
            }
        }
        catch (AMQInvalidRoutingKeyException rke)
        {
            throw body.getChannelException(AMQConstant.INVALID_ROUTING_KEY, body.routingKey.toString());
        }
        catch (AMQException e)
        {
            throw body.getChannelException(AMQConstant.CHANNEL_ERROR, e.toString());
        }

        if (_log.isInfoEnabled())
        {
            _log.info("Binding queue " + queue + " to exchange " + exch + " with routing key " + body.routingKey);
View Full Code Here


    public void methodReceived(AMQStateManager stateManager, QueueRegistry queueRegistry,
                               ExchangeRegistry exchangeRegistry, AMQProtocolSession protocolSession,
                               AMQMethodEvent<QueueBindBody> evt) throws AMQException
    {
        final QueueBindBody body = evt.getMethod();
        final AMQQueue queue;
        if (body.queue == null)
        {
            queue = protocolSession.getChannel(evt.getChannelId()).getDefaultQueue();
            if (queue == null)
            {
                throw new AMQException("No default queue defined on channel and queue was null");
            }
            if (body.routingKey == null)
            {
                body.routingKey = queue.getName();
            }
        }
        else
        {
            queue = queueRegistry.getQueue(body.queue);
        }

        if (queue == null)
        {
            throw body.getChannelException(AMQConstant.NOT_FOUND.getCode(), "Queue " + body.queue + " does not exist.");
        }
        final Exchange exch = exchangeRegistry.getExchange(body.exchange);
        if (exch == null)
        {
            throw body.getChannelException(AMQConstant.NOT_FOUND.getCode(), "Exchange " + body.exchange + " does not exist.");
        }
        exch.registerQueue(body.routingKey, queue, body.arguments);
        queue.bind(body.routingKey, exch);
        if (_log.isInfoEnabled())
        {
View Full Code Here

TOP

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

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.