Package org.apache.qpid.client.protocol

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


        // Mina filter chain and interrupt processing.
        // this has been raised as QPID-2138
        _session.createConsumer(_session.createTemporaryQueue()).close();

        //Retain IO Layer
        AMQProtocolSession protocolSession = _connection.getProtocolHandler().getProtocolSession();

        // Send IO Exception - causing failover
        _connection.getProtocolHandler().
                exception(new WriteTimeoutException("WriteTimeoutException to cause failover."));
View Full Code Here


            // Test connection
            checkSendingMessage();

            // Set StateManager to manager that ignores Close-oks
            AMQProtocolSession protocolSession = ((AMQConnection) _connection).getProtocolHandler().getProtocolSession();
            AMQStateManager newStateManager = new NoCloseOKStateManager(protocolSession);
            newStateManager.changeState(oldStateManager.getCurrentState());

            ((AMQConnection) _connection).getProtocolHandler().setStateManager(newStateManager);
View Full Code Here

        // Mina filter chain and interrupt processing.
        // this has been raised as QPID-2138
        _session.createConsumer(_session.createTemporaryQueue()).close();

        //Retain IO Layer
        AMQProtocolSession protocolSession = _connection.getProtocolHandler().getProtocolSession();

        // Send IO Exception - causing failover
        _connection.getProtocolHandler().
                exception(new IOException("IOException to cause failover."));
View Full Code Here

    {
    }

    public void methodReceived(AMQStateManager stateManager, AMQMethodEvent evt) throws AMQException
    {
        AMQProtocolSession session = evt.getProtocolSession();
        ConnectionOpenOkBody method = (ConnectionOpenOkBody) evt.getMethod();       
        stateManager.changeState(AMQState.CONNECTION_OPEN);
    }
View Full Code Here

    public void methodReceived(AMQStateManager stateManager, AMQMethodEvent evt) throws AMQException
    {
        _logger.debug("ConnectionTune frame received");
        ConnectionTuneBody frame = (ConnectionTuneBody) evt.getMethod();
        AMQProtocolSession session = evt.getProtocolSession();

        ConnectionTuneParameters params = session.getConnectionTuneParameters();
        if (params == null)
        {
            params = new ConnectionTuneParameters();
        }

        params.setFrameMax(frame.frameMax);       
        params.setChannelMax(frame.channelMax);
        params.setHeartbeat(Integer.getInteger("amqj.heartbeat.delay", frame.heartbeat));
        session.setConnectionTuneParameters(params);

        stateManager.changeState(AMQState.CONNECTION_NOT_OPENED);
        session.writeFrame(createTuneOkFrame(evt.getChannelId(), params));
        session.writeFrame(createConnectionOpenFrame(evt.getChannelId(), session.getAMQConnection().getVirtualHost(), null, true));
    }
View Full Code Here

            if (mechanism == null)
            {
                throw new AMQException("No supported security mechanism found, passed: " + new String(body.mechanisms));
            }

            final AMQProtocolSession ps = evt.getProtocolSession();
            byte[] saslResponse;
            try
            {
                SaslClient sc = Sasl.createSaslClient(new String[]{mechanism},
                                                      null, "AMQP", "localhost",
                                                      null, createCallbackHandler(mechanism, ps));
                if (sc == null)
                {
                    throw new AMQException("Client SASL configuration error: no SaslClient could be created for mechanism " +
                                           mechanism + ". Please ensure all factories are registered. See DynamicSaslRegistrar for " +
                                           " details of how to register non-standard SASL client providers.");
                }
                ps.setSaslClient(sc);
                saslResponse = (sc.hasInitialResponse() ? sc.evaluateChallenge(new byte[0]) : null);
            }
            catch (SaslException e)
            {
                ps.setSaslClient(null);
                throw new AMQException("Unable to create SASL client: " + e, e);
            }

            if (body.locales == null)
            {
                throw new AMQException("Locales is not defined in Connection Start method");
            }
            final String locales = new String(body.locales, "utf8");
            final StringTokenizer tokenizer = new StringTokenizer(locales, " ");
            String selectedLocale = null;
            if (tokenizer.hasMoreTokens())
            {
                selectedLocale = tokenizer.nextToken();
            }
            else
            {
                throw new AMQException("No locales sent from server, passed: " + locales);
            }

            stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);
            FieldTable clientProperties = new FieldTable();
            clientProperties.put("instance", ps.getClientID());
            clientProperties.put("product", "Qpid");
            clientProperties.put("version", "1.0");
            clientProperties.put("platform", getFullSystemInfo());
            ps.writeFrame(ConnectionStartOkBody.createAMQFrame(evt.getChannelId(), clientProperties, mechanism,
                                                               saslResponse, selectedLocale));
        }
        catch (UnsupportedEncodingException e)
        {
            throw new AMQException(_log, "Unable to decode data: " + e, e);
View Full Code Here

        // Mina filter chain and interrupt processing.
        // this has been raised as QPID-2138
        _session.createConsumer(_session.createTemporaryQueue()).close();

        //Retain IO Layer
        AMQProtocolSession protocolSession = _connection.getProtocolHandler().getProtocolSession();

        // Send IO Exception - causing failover
        _connection.getProtocolHandler().
                exception(new WriteTimeoutException("WriteTimeoutException to cause failover."));
View Full Code Here

    public void methodReceived(AMQStateManager stateManager, ConnectionCloseBody method, int channelId)
                throws AMQException
    {
        _logger.info("ConnectionClose frame received");
        final AMQProtocolSession session = stateManager.getProtocolSession();
       

        // does it matter
        // stateManager.changeState(AMQState.CONNECTION_CLOSING);

        AMQConstant errorCode = AMQConstant.getConstant(method.getReplyCode());
        AMQShortString reason = method.getReplyText();

        try
        {

            ConnectionCloseOkBody closeOkBody = session.getMethodRegistry().createConnectionCloseOkBody();
            // TODO: check whether channel id of zero is appropriate
            // Be aware of possible changes to parameter order as versions change.
            session.writeFrame(closeOkBody.generateFrame(0));

            if (errorCode != AMQConstant.REPLY_SUCCESS)
            {
                if (errorCode == AMQConstant.NOT_ALLOWED || (errorCode == AMQConstant.ACCESS_REFUSED))
                {
                    _logger.info("Error :" + errorCode +":"+ Thread.currentThread().getName());

                    // todo ritchiem : Why do this here when it is going to be done in the finally block?
                    session.closeProtocolSession();

                    // todo this is a bit of a fudge (could be conssidered such as each new connection needs a new state manager or at least a fresh state.
                    stateManager.changeState(AMQState.CONNECTION_NOT_STARTED);

                    throw new AMQAuthenticationException(errorCode, (reason == null) ? null : reason.toString());
                }
                else
                {
                    _logger.info("Connection close received with error code " + errorCode);

                    throw new AMQConnectionClosedException(errorCode, "Error: " + reason);
                }
            }
        }
        finally
        {
            // this actually closes the connection in the case where it is not an error.

            session.closeProtocolSession();

            // ritchiem: Doing this though will cause any waiting connection start to be released without being able to
            // see what the cause was.
            stateManager.changeState(AMQState.CONNECTION_CLOSED);
        }
View Full Code Here

    public void methodReceived(AMQStateManager stateManager, ChannelFlowBody body, int channelId)
            throws AMQException
    {

        final AMQProtocolSession session = stateManager.getProtocolSession();
        session.setFlowControl(channelId, body.getActive());
    }
View Full Code Here

    }

    public void methodReceived(AMQStateManager stateManager, ConnectionSecureBody body, int channelId)
                throws AMQException
    {
        final AMQProtocolSession session = stateManager.getProtocolSession();
        SaslClient client = session.getSaslClient();
        if (client == null)
        {
            throw new AMQException("No SASL client set up - cannot proceed with authentication");
        }



        try
        {
            // Evaluate server challenge
            byte[] response = client.evaluateChallenge(body.getChallenge());

            ConnectionSecureOkBody secureOkBody = session.getMethodRegistry().createConnectionSecureOkBody(response);

            session.writeFrame(secureOkBody.generateFrame(channelId));
        }
        catch (SaslException e)
        {
            throw new AMQException("Error processing SASL challenge: " + e, e);
        }
View Full Code Here

TOP

Related Classes of org.apache.qpid.client.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.