Package org.apache.qpid.framing

Examples of org.apache.qpid.framing.MethodRegistry


    public void closeSession(AMQSessionModel session, AMQConstant cause, String message) throws AMQException
    {
        int channelId = ((AMQChannel)session).getChannelId();
        closeChannel(channelId, cause, message);

        MethodRegistry methodRegistry = getMethodRegistry();
        ChannelCloseBody responseBody =
                methodRegistry.createChannelCloseBody(
                        cause.getCode(),
                        new AMQShortString(message),
                        0,0);

        writeFrame(responseBody.generateFrame(channelId));
View Full Code Here


    { }

    public void methodReceived(AMQProtocolSession session, ConnectionTuneBody frame, int channelId)
    {
        _logger.debug("ConnectionTune frame received");
        final MethodRegistry methodRegistry = session.getMethodRegistry();

        ConnectionTuneParameters params = session.getConnectionTuneParameters();

        int maxChannelNumber = frame.getChannelMax();
        //0 implies no limit, except that forced by protocol limitations (0xFFFF)
        params.setChannelMax(maxChannelNumber == 0 ? AMQProtocolSession.MAX_CHANNEL_MAX : maxChannelNumber);
        params.setFrameMax(frame.getFrameMax());

        //if the heart beat delay hasn't been configured, we use the broker-supplied value
        if (params.getHeartbeat() == null)
        {
            params.setHeartbeat(frame.getHeartbeat());
        }

        session.tuneConnection(params);

        session.getStateManager().changeState(AMQState.CONNECTION_NOT_OPENED);

        ConnectionTuneOkBody tuneOkBody = methodRegistry.createConnectionTuneOkBody(params.getChannelMax(),
                                                                                    params.getFrameMax(),
                                                                                    params.getHeartbeat());
        // Be aware of possible changes to parameter order as versions change.
        session.writeFrame(tuneOkBody.generateFrame(channelId));

        String host = session.getAMQConnection().getVirtualHost();
        AMQShortString virtualHost = new AMQShortString("/" + host);

        ConnectionOpenBody openBody = methodRegistry.createConnectionOpenBody(virtualHost,null,true);

        // Be aware of possible changes to parameter order as versions change.
        session.writeFrame(openBody.generateFrame(channelId));
    }
View Full Code Here

                    }
                }

                if (!performGet(queue,protocolConnection, channel, !body.getNoAck()))
                {
                    MethodRegistry methodRegistry = protocolConnection.getMethodRegistry();
                    // TODO - set clusterId
                    BasicGetEmptyBody responseBody = methodRegistry.createBasicGetEmptyBody(null);


                    protocolConnection.writeFrame(responseBody.generateFrame(channelId));
                }
            }
View Full Code Here

        SaslServer ss = session.getSaslServer();
        if (ss == null)
        {
            throw new AMQException("No SASL context set up in session");
        }
        MethodRegistry methodRegistry = session.getMethodRegistry();
        AuthenticationResult authResult = authMgr.authenticate(ss, body.getResponse());
        switch (authResult.getStatus())
        {
            case ERROR:
                Exception cause = authResult.getCause();

                _logger.info("Authentication failed:" + (cause == null ? "" : cause.getMessage()));

                // This should be abstracted
                stateManager.changeState(AMQState.CONNECTION_CLOSING);

                ConnectionCloseBody connectionCloseBody =
                        methodRegistry.createConnectionCloseBody(AMQConstant.NOT_ALLOWED.getCode(),
                                                                 AMQConstant.NOT_ALLOWED.getName(),
                                                                 body.getClazz(),
                                                                 body.getMethod());

                session.writeFrame(connectionCloseBody.generateFrame(0));
                disposeSaslServer(session);
                break;
            case SUCCESS:
                _logger.info("Connected as: " + ss.getAuthorizationID());
                stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);

                ConnectionTuneBody tuneBody =
                        methodRegistry.createConnectionTuneBody(ApplicationRegistry.getInstance().getConfiguration().getMaxChannelCount(),
                                                                ConnectionStartOkMethodHandler.getConfiguredFrameSize(),
                                                                ApplicationRegistry.getInstance().getConfiguration().getHeartBeatDelay());
                session.writeFrame(tuneBody.generateFrame(0));
                final UsernamePrincipal principal = UsernamePrincipal.getUsernamePrincipalFromSubject(authResult.getSubject());
                session.setAuthorizedID(principal);
                disposeSaslServer(session);               
                break;
            case CONTINUE:
                stateManager.changeState(AMQState.CONNECTION_NOT_AUTH);

                ConnectionSecureBody secureBody = methodRegistry.createConnectionSecureBody(authResult.getChallenge());
                session.writeFrame(secureBody.generateFrame(0));
        }
    }
View Full Code Here

            if (session.getClientProperties() == null)
            {
                session.setClientProperties(body.getClientProperties());
            }

            MethodRegistry methodRegistry = session.getMethodRegistry();

            switch (authResult.getStatus())
            {
                case ERROR:
                    Exception cause = authResult.getCause();

                    _logger.info("Authentication failed:" + (cause == null ? "" : cause.getMessage()));

                    stateManager.changeState(AMQState.CONNECTION_CLOSING);

                    ConnectionCloseBody closeBody =
                            methodRegistry.createConnectionCloseBody(AMQConstant.NOT_ALLOWED.getCode(),    // replyCode
                                                                     AMQConstant.NOT_ALLOWED.getName(),
                                                                     body.getClazz(),
                                                                     body.getMethod());

                    session.writeFrame(closeBody.generateFrame(0));
                    disposeSaslServer(session);
                    break;

                case SUCCESS:
                    _logger.info("Connected as: " + ss.getAuthorizationID());
                    session.setAuthorizedID(new UsernamePrincipal(ss.getAuthorizationID()));

                    stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);

                    ConnectionTuneBody tuneBody = methodRegistry.createConnectionTuneBody(ApplicationRegistry.getInstance().getConfiguration().getMaxChannelCount(),
                                                                                          getConfiguredFrameSize(),
                                                                                          ApplicationRegistry.getInstance().getConfiguration().getHeartBeatDelay());
                    session.writeFrame(tuneBody.generateFrame(0));
                    break;
                case CONTINUE:
                    stateManager.changeState(AMQState.CONNECTION_NOT_AUTH);

                    ConnectionSecureBody secureBody = methodRegistry.createConnectionSecureBody(authResult.getChallenge());
                    session.writeFrame(secureBody.generateFrame(0));
            }
        }
        catch (SaslException e)
        {
View Full Code Here

     * @throws JMException
     */
    public void closeConnection() throws JMException
    {

        MethodRegistry methodRegistry = _protocolSession.getMethodRegistry();
        ConnectionCloseBody responseBody =
                methodRegistry.createConnectionCloseBody(AMQConstant.REPLY_SUCCESS.getCode(),
                                                         // replyCode
                                                         BROKER_MANAGEMENT_CONSOLE_HAS_CLOSED_THE_CONNECTION,
                                                         // replyText,
                                                         0,
                                                         0);
View Full Code Here

            channel.setDefaultQueue(queue);
        }

        if (!body.getNowait())
        {
            MethodRegistry methodRegistry = protocolConnection.getMethodRegistry();
            QueueDeclareOkBody responseBody =
                    methodRegistry.createQueueDeclareOkBody(queueName,
                                                            queue.getMessageCount(),
                                                            queue.getConsumerCount());
            protocolConnection.writeFrame(responseBody.generateFrame(channelId));

            _logger.info("Queue " + queueName + " declared successfully");
View Full Code Here

        else
        {
            _logger.error("Exception caught in" + this + ", closing session explictly: " + throwable, throwable);


            MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(getProtocolVersion());
            ConnectionCloseBody closeBody = methodRegistry.createConnectionCloseBody(200,new AMQShortString(throwable.getMessage()),0,0);

            writeFrame(closeBody.generateFrame(0));

            _networkDriver.close();
        }
View Full Code Here

        return false;
    }
   
    public void mgmtClose()
    {
        MethodRegistry methodRegistry = getMethodRegistry();
        ConnectionCloseBody responseBody =
                methodRegistry.createConnectionCloseBody(
                        AMQConstant.REPLY_SUCCESS.getCode(),
                        new AMQShortString("The connection was closed using the broker's management interface."),
                        0,0);

        // This seems ugly but because we use closeConnection in both normal
View Full Code Here

        }
    }

    public void mgmtCloseChannel(int channelId)
    {
        MethodRegistry methodRegistry = getMethodRegistry();
        ChannelCloseBody responseBody =
                methodRegistry.createChannelCloseBody(
                        AMQConstant.REPLY_SUCCESS.getCode(),
                        new AMQShortString("The channel was closed using the broker's management interface."),
                        0,0);

        // This seems ugly but because we use AMQChannel.close() in both normal
View Full Code Here

TOP

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

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.