Search in sources :

Example 1 with NettyRequestProcessor

use of org.apache.rocketmq.remoting.netty.NettyRequestProcessor in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class BrokerController method registerProcessor.

public void registerProcessor() {
    /**
     * SendMessageProcessor
     */
    // 处理客户端发送消息的请求
    SendMessageProcessor sendProcessor = new SendMessageProcessor(this);
    sendMessageHookList.add(new SendMessageHookImpl());
    sendProcessor.registerSendMessageHook(sendMessageHookList);
    consumeMessageHookList.add(new ConsumeMessageHookImpl());
    sendProcessor.registerConsumeMessageHook(consumeMessageHookList);
    // RemotingServer在注册processor的时候,是根据RequestCode进行注册的。
    this.remotingServer.registerProcessor(RequestCode.SEND_MESSAGE, sendProcessor, this.sendMessageExecutor);
    this.remotingServer.registerProcessor(RequestCode.SEND_MESSAGE_V2, sendProcessor, this.sendMessageExecutor);
    this.remotingServer.registerProcessor(RequestCode.SEND_BATCH_MESSAGE, sendProcessor, this.sendMessageExecutor);
    this.remotingServer.registerProcessor(RequestCode.CONSUMER_SEND_MSG_BACK, sendProcessor, this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.SEND_MESSAGE, sendProcessor, this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.SEND_MESSAGE_V2, sendProcessor, this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.SEND_BATCH_MESSAGE, sendProcessor, this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.CONSUMER_SEND_MSG_BACK, sendProcessor, this.sendMessageExecutor);
    /**
     * PullMessageProcessor  11  这个在分析consumer有关系
     */
    this.remotingServer.registerProcessor(RequestCode.PULL_MESSAGE, this.pullMessageProcessor, this.pullMessageExecutor);
    this.pullMessageProcessor.registerConsumeMessageHook(consumeMessageHookList);
    /**
     * QueryMessageProcessor
     */
    NettyRequestProcessor queryProcessor = new QueryMessageProcessor(this);
    this.remotingServer.registerProcessor(RequestCode.QUERY_MESSAGE, queryProcessor, this.pullMessageExecutor);
    this.remotingServer.registerProcessor(RequestCode.VIEW_MESSAGE_BY_ID, queryProcessor, this.pullMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.QUERY_MESSAGE, queryProcessor, this.pullMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.VIEW_MESSAGE_BY_ID, queryProcessor, this.pullMessageExecutor);
    /**
     * ClientManageProcessor
     */
    ClientManageProcessor clientProcessor = new ClientManageProcessor(this);
    this.remotingServer.registerProcessor(RequestCode.HEART_BEAT, clientProcessor, this.clientManageExecutor);
    this.remotingServer.registerProcessor(RequestCode.UNREGISTER_CLIENT, clientProcessor, this.clientManageExecutor);
    this.remotingServer.registerProcessor(RequestCode.CHECK_CLIENT_CONFIG, clientProcessor, this.clientManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.HEART_BEAT, clientProcessor, this.clientManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.UNREGISTER_CLIENT, clientProcessor, this.clientManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.CHECK_CLIENT_CONFIG, clientProcessor, this.clientManageExecutor);
    /**
     * ConsumerManageProcessor
     */
    ConsumerManageProcessor consumerManageProcessor = new ConsumerManageProcessor(this);
    this.remotingServer.registerProcessor(RequestCode.GET_CONSUMER_LIST_BY_GROUP, consumerManageProcessor, this.consumerManageExecutor);
    this.remotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
    this.remotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.GET_CONSUMER_LIST_BY_GROUP, consumerManageProcessor, this.consumerManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
    /**
     * EndTransactionProcessor
     */
    this.remotingServer.registerProcessor(RequestCode.END_TRANSACTION, new EndTransactionProcessor(this), this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.END_TRANSACTION, new EndTransactionProcessor(this), this.sendMessageExecutor);
    /**
     * Default
     */
    AdminBrokerProcessor adminProcessor = new AdminBrokerProcessor(this);
    this.remotingServer.registerDefaultProcessor(adminProcessor, this.adminBrokerExecutor);
    this.fastRemotingServer.registerDefaultProcessor(adminProcessor, this.adminBrokerExecutor);
}
Also used : QueryMessageProcessor(org.apache.rocketmq.broker.processor.QueryMessageProcessor) SendMessageProcessor(org.apache.rocketmq.broker.processor.SendMessageProcessor) ConsumeMessageHookImpl(org.apache.rocketmq.broker.mqtrace.ConsumeMessageHookImpl) EndTransactionProcessor(org.apache.rocketmq.broker.processor.EndTransactionProcessor) ClientManageProcessor(org.apache.rocketmq.broker.processor.ClientManageProcessor) SendMessageHookImpl(org.apache.rocketmq.broker.mqtrace.SendMessageHookImpl) ConsumerManageProcessor(org.apache.rocketmq.broker.processor.ConsumerManageProcessor) AdminBrokerProcessor(org.apache.rocketmq.broker.processor.AdminBrokerProcessor) NettyRequestProcessor(org.apache.rocketmq.remoting.netty.NettyRequestProcessor)

Example 2 with NettyRequestProcessor

use of org.apache.rocketmq.remoting.netty.NettyRequestProcessor in project rocketmq by apache.

the class RequestHeader method createRemotingServer.

public static RemotingServer createRemotingServer() throws InterruptedException {
    NettyServerConfig config = new NettyServerConfig();
    RemotingServer remotingServer = new NettyRemotingServer(config);
    remotingServer.registerProcessor(0, new NettyRequestProcessor() {

        @Override
        public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
            request.setRemark("Hi " + ctx.channel().remoteAddress());
            return request;
        }

        @Override
        public boolean rejectRequest() {
            return false;
        }
    }, Executors.newCachedThreadPool());
    remotingServer.start();
    return remotingServer;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) NettyRemotingServer(org.apache.rocketmq.remoting.netty.NettyRemotingServer) NettyRemotingServer(org.apache.rocketmq.remoting.netty.NettyRemotingServer) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) NettyRequestProcessor(org.apache.rocketmq.remoting.netty.NettyRequestProcessor)

Example 3 with NettyRequestProcessor

use of org.apache.rocketmq.remoting.netty.NettyRequestProcessor in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class RequestHeader method createRemotingServer.

public static RemotingServer createRemotingServer() throws InterruptedException {
    NettyServerConfig config = new NettyServerConfig();
    RemotingServer remotingServer = new NettyRemotingServer(config);
    remotingServer.registerProcessor(0, new NettyRequestProcessor() {

        @Override
        public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
            request.setRemark("Hi " + ctx.channel().remoteAddress());
            return request;
        }

        @Override
        public boolean rejectRequest() {
            return false;
        }
    }, Executors.newCachedThreadPool());
    remotingServer.start();
    return remotingServer;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) NettyRemotingServer(org.apache.rocketmq.remoting.netty.NettyRemotingServer) NettyRemotingServer(org.apache.rocketmq.remoting.netty.NettyRemotingServer) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) NettyServerConfig(org.apache.rocketmq.remoting.netty.NettyServerConfig) NettyRequestProcessor(org.apache.rocketmq.remoting.netty.NettyRequestProcessor)

Example 4 with NettyRequestProcessor

use of org.apache.rocketmq.remoting.netty.NettyRequestProcessor in project rocketmq by apache.

the class BrokerController method registerProcessor.

public void registerProcessor() {
    /**
     * SendMessageProcessor
     */
    SendMessageProcessor sendProcessor = new SendMessageProcessor(this);
    sendProcessor.registerSendMessageHook(sendMessageHookList);
    sendProcessor.registerConsumeMessageHook(consumeMessageHookList);
    this.remotingServer.registerProcessor(RequestCode.SEND_MESSAGE, sendProcessor, this.sendMessageExecutor);
    this.remotingServer.registerProcessor(RequestCode.SEND_MESSAGE_V2, sendProcessor, this.sendMessageExecutor);
    this.remotingServer.registerProcessor(RequestCode.SEND_BATCH_MESSAGE, sendProcessor, this.sendMessageExecutor);
    this.remotingServer.registerProcessor(RequestCode.CONSUMER_SEND_MSG_BACK, sendProcessor, this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.SEND_MESSAGE, sendProcessor, this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.SEND_MESSAGE_V2, sendProcessor, this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.SEND_BATCH_MESSAGE, sendProcessor, this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.CONSUMER_SEND_MSG_BACK, sendProcessor, this.sendMessageExecutor);
    /**
     * PullMessageProcessor
     */
    this.remotingServer.registerProcessor(RequestCode.PULL_MESSAGE, this.pullMessageProcessor, this.pullMessageExecutor);
    this.pullMessageProcessor.registerConsumeMessageHook(consumeMessageHookList);
    /**
     * QueryMessageProcessor
     */
    NettyRequestProcessor queryProcessor = new QueryMessageProcessor(this);
    this.remotingServer.registerProcessor(RequestCode.QUERY_MESSAGE, queryProcessor, this.queryMessageExecutor);
    this.remotingServer.registerProcessor(RequestCode.VIEW_MESSAGE_BY_ID, queryProcessor, this.queryMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.QUERY_MESSAGE, queryProcessor, this.queryMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.VIEW_MESSAGE_BY_ID, queryProcessor, this.queryMessageExecutor);
    /**
     * ClientManageProcessor
     */
    ClientManageProcessor clientProcessor = new ClientManageProcessor(this);
    this.remotingServer.registerProcessor(RequestCode.HEART_BEAT, clientProcessor, this.clientManageExecutor);
    this.remotingServer.registerProcessor(RequestCode.UNREGISTER_CLIENT, clientProcessor, this.clientManageExecutor);
    this.remotingServer.registerProcessor(RequestCode.CHECK_CLIENT_CONFIG, clientProcessor, this.clientManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.HEART_BEAT, clientProcessor, this.clientManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.UNREGISTER_CLIENT, clientProcessor, this.clientManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.CHECK_CLIENT_CONFIG, clientProcessor, this.clientManageExecutor);
    /**
     * ConsumerManageProcessor
     */
    ConsumerManageProcessor consumerManageProcessor = new ConsumerManageProcessor(this);
    this.remotingServer.registerProcessor(RequestCode.GET_CONSUMER_LIST_BY_GROUP, consumerManageProcessor, this.consumerManageExecutor);
    this.remotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
    this.remotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.GET_CONSUMER_LIST_BY_GROUP, consumerManageProcessor, this.consumerManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
    /**
     * EndTransactionProcessor
     */
    this.remotingServer.registerProcessor(RequestCode.END_TRANSACTION, new EndTransactionProcessor(this), this.sendMessageExecutor);
    this.fastRemotingServer.registerProcessor(RequestCode.END_TRANSACTION, new EndTransactionProcessor(this), this.sendMessageExecutor);
    /**
     * Default
     */
    AdminBrokerProcessor adminProcessor = new AdminBrokerProcessor(this);
    this.remotingServer.registerDefaultProcessor(adminProcessor, this.adminBrokerExecutor);
    this.fastRemotingServer.registerDefaultProcessor(adminProcessor, this.adminBrokerExecutor);
}
Also used : QueryMessageProcessor(org.apache.rocketmq.broker.processor.QueryMessageProcessor) SendMessageProcessor(org.apache.rocketmq.broker.processor.SendMessageProcessor) EndTransactionProcessor(org.apache.rocketmq.broker.processor.EndTransactionProcessor) ClientManageProcessor(org.apache.rocketmq.broker.processor.ClientManageProcessor) ConsumerManageProcessor(org.apache.rocketmq.broker.processor.ConsumerManageProcessor) AdminBrokerProcessor(org.apache.rocketmq.broker.processor.AdminBrokerProcessor) NettyRequestProcessor(org.apache.rocketmq.remoting.netty.NettyRequestProcessor)

Aggregations

NettyRequestProcessor (org.apache.rocketmq.remoting.netty.NettyRequestProcessor)4 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2 AdminBrokerProcessor (org.apache.rocketmq.broker.processor.AdminBrokerProcessor)2 ClientManageProcessor (org.apache.rocketmq.broker.processor.ClientManageProcessor)2 ConsumerManageProcessor (org.apache.rocketmq.broker.processor.ConsumerManageProcessor)2 EndTransactionProcessor (org.apache.rocketmq.broker.processor.EndTransactionProcessor)2 QueryMessageProcessor (org.apache.rocketmq.broker.processor.QueryMessageProcessor)2 SendMessageProcessor (org.apache.rocketmq.broker.processor.SendMessageProcessor)2 NettyRemotingServer (org.apache.rocketmq.remoting.netty.NettyRemotingServer)2 NettyServerConfig (org.apache.rocketmq.remoting.netty.NettyServerConfig)2 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)2 ConsumeMessageHookImpl (org.apache.rocketmq.broker.mqtrace.ConsumeMessageHookImpl)1 SendMessageHookImpl (org.apache.rocketmq.broker.mqtrace.SendMessageHookImpl)1