Package org.apache.qpid.framing

Examples of org.apache.qpid.framing.ExchangeDeclareBody


    }

    private void declareExchange(int channelId, String _type, String _name, boolean nowait)
        throws AMQException, FailoverException
    {
        ExchangeDeclareBody body =
                ((AMQConnection) _connection).getProtocolHandler()
                        .getMethodRegistry()
                        .createExchangeDeclareBody(0,
                                                   new AMQShortString(_name),
                                                   new AMQShortString(_type),
                                                   true,
                                                   false,
                                                   false,
                                                   false,
                                                   nowait,
                                                   null);
                AMQFrame exchangeDeclare = body.generateFrame(channelId);
                AMQProtocolHandler protocolHandler = ((AMQConnection) _connection).getProtocolHandler();


                if (nowait)
                {
View Full Code Here


        AMQSession session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        // Set no wait true so that we block the connection
        // Also set a different exchange class string so the attempt to declare
        // the exchange causes an exchange.
        ExchangeDeclareBody body = session.getMethodRegistry().createExchangeDeclareBody(session.getTicket(), new AMQShortString(EXCHANGE_NAME), null,
                                                                                         true, false, false, false, true, null);

        AMQFrame exchangeDeclare = body.generateFrame(session.getChannelId());

        try
        {
            // block our thread so that can times out
            connection.getProtocolHandler().syncWrite(exchangeDeclare, ExchangeDeclareOkBody.class);
View Full Code Here

    void declareDestination(AMQDestination destination)
    {

        final MethodRegistry methodRegistry = getSession().getMethodRegistry();
        ExchangeDeclareBody body =
                methodRegistry.createExchangeDeclareBody(getSession().getTicket(),
                                                         destination.getExchangeName(),
                                                         destination.getExchangeClass(),
                                                         destination.getExchangeName().toString().startsWith("amq."),
                                                         false,
                                                         false,
                                                         false,
                                                         true,
                                                         null);
        // Declare the exchange
        // Note that the durable and internal arguments are ignored since passive is set to false

        AMQFrame declare = body.generateFrame(getChannelId());

        getProtocolHandler().writeFrame(declare);
    }
View Full Code Here

    void declareDestination(AMQDestination destination)
    {
        if(getSession().isDeclareExchanges())
        {
            final MethodRegistry methodRegistry = getSession().getMethodRegistry();
            ExchangeDeclareBody body =
                methodRegistry.createExchangeDeclareBody(getSession().getTicket(),
                                                         destination.getExchangeName(),
                                                         destination.getExchangeClass(),
                                                         destination.getExchangeName().toString().startsWith("amq."),
                                                         destination.isExchangeDurable(),
                                                         destination.isExchangeAutoDelete(),
                                                         destination.isExchangeInternal(),
                                                         true,
                                                         null);
            AMQFrame declare = body.generateFrame(getChannelId());

            getConnection().getProtocolHandler().writeFrame(declare);
        }
    }
View Full Code Here

    }

    void declareDestination(AMQDestination destination)
    {

        ExchangeDeclareBody body = getSession().getMethodRegistry().createExchangeDeclareBody(_session.getTicket(),
                                                                                              destination.getExchangeName(),
                                                                                              destination.getExchangeClass(),
                                                                                              false,
                                                                                              false,
                                                                                              false,
                                                                                              false,
                                                                                              true,
                                                                                              null);
        // Declare the exchange
        // Note that the durable and internal arguments are ignored since passive is set to false

        AMQFrame declare = body.generateFrame(_channelId);

        _protocolHandler.writeFrame(declare);
    }
View Full Code Here

    }

    public void sendExchangeDeclare(final AMQShortString name, final AMQShortString type, final AMQProtocolHandler protocolHandler,
            final boolean nowait) throws AMQException, FailoverException
    {
        ExchangeDeclareBody body = getMethodRegistry().createExchangeDeclareBody(getTicket(),name,type,
                                                                                 name.toString().startsWith("amq."),
                                                                                 false,false,false,false,null);
        AMQFrame exchangeDeclare = body.generateFrame(_channelId);

        protocolHandler.syncWrite(exchangeDeclare, ExchangeDeclareOkBody.class);
    }
View Full Code Here

    }

    void declareDestination(AMQDestination destination)
    {

        ExchangeDeclareBody body = getSession().getMethodRegistry().createExchangeDeclareBody(_session.getTicket(),
                                                                                              destination.getExchangeName(),
                                                                                              destination.getExchangeClass(),
                                                                                              false,
                                                                                              false,
                                                                                              false,
                                                                                              false,
                                                                                              true,
                                                                                              null);
        // Declare the exchange
        // Note that the durable and internal arguments are ignored since passive is set to false

        AMQFrame declare = body.generateFrame(_channelId);

        _protocolHandler.writeFrame(declare);
    }
View Full Code Here

        AMQProtocolSession session = stateManager.getProtocolSession();
        VirtualHost virtualHost = session.getVirtualHost();
        ExchangeRegistry exchangeRegistry = virtualHost.getExchangeRegistry();
        ExchangeFactory exchangeFactory = virtualHost.getExchangeFactory();
       
        final ExchangeDeclareBody body = evt.getMethod();
        if (_logger.isDebugEnabled())
        {
            _logger.debug("Request to declare exchange of type " + body.type + " with name " + body.exchange);
        }
        synchronized(exchangeRegistry)
        {
            Exchange exchange = exchangeRegistry.getExchange(body.exchange);



            if (exchange == null)
            {
                if(body.passive && ((body.type == null) || body.type.length() ==0))
                {
                    throw body.getChannelException(AMQConstant.NOT_FOUND, "Unknown exchange: " + body.exchange);                   
                }
                else
                {
                    try
                    {

                    exchange = exchangeFactory.createExchange(body.exchange == null ? null : body.exchange.intern(),
                                                              body.type == null ? null : body.type.intern(),
                                                              body.durable,
                                                              body.passive, body.ticket);
                    exchangeRegistry.registerExchange(exchange);
                    }
                    catch(AMQUnknownExchangeType e)
                    {
                        throw body.getConnectionException(AMQConstant.COMMAND_INVALID, "Unknown exchange: " + body.exchange,e);
                    }
                }
            }
            else if (!exchange.getType().equals(body.type))
            {

                throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " + body.exchange + " of type " + exchange.getType() + " to " + body.type +".",body.getClazz(), body.getMethod(),body.getMajor(),body.getMinor());   
            }

        }
        if(!body.nowait)
        {
View Full Code Here

        AMQSession session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        // Set no wait true so that we block the connection
        // Also set a different exchange class string so the attempt to declare
        // the exchange causes an exchange.
        ExchangeDeclareBody body = session.getMethodRegistry().createExchangeDeclareBody(session.getTicket(), new AMQShortString(EXCHANGE_NAME), null,
                                                                                         true, false, false, false, true, null);

        AMQFrame exchangeDeclare = body.generateFrame(session.getChannelId());

        try
        {
            // block our thread so that can times out
            connection.getProtocolHandler().syncWrite(exchangeDeclare, ExchangeDeclareOkBody.class);
View Full Code Here

    }

    public void sendExchangeDeclare(final AMQShortString name, final AMQShortString type, final AMQProtocolHandler protocolHandler,
            final boolean nowait) throws AMQException, FailoverException
    {
        ExchangeDeclareBody body = getMethodRegistry().createExchangeDeclareBody(getTicket(),name,type,
                                                                                 name.toString().startsWith("amq."),
                                                                                 false,false,false,false,null);
        AMQFrame exchangeDeclare = body.generateFrame(_channelId);

        protocolHandler.syncWrite(exchangeDeclare, ExchangeDeclareOkBody.class);
    }
View Full Code Here

TOP

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

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.