Search in sources :

Example 46 with NettyServerConfig

use of org.apache.rocketmq.remoting.netty.NettyServerConfig 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)

Aggregations

NettyServerConfig (org.apache.rocketmq.remoting.netty.NettyServerConfig)46 NamesrvConfig (org.apache.rocketmq.common.namesrv.NamesrvConfig)23 NamesrvController (org.apache.rocketmq.namesrv.NamesrvController)20 MQClientException (org.apache.rocketmq.client.exception.MQClientException)17 BrokerConfig (org.apache.rocketmq.common.BrokerConfig)17 NettyClientConfig (org.apache.rocketmq.remoting.netty.NettyClientConfig)17 MessageStoreConfig (org.apache.rocketmq.store.config.MessageStoreConfig)17 BrokerController (org.apache.rocketmq.broker.BrokerController)13 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)8 LoggerContext (ch.qos.logback.classic.LoggerContext)6 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)6 BufferedInputStream (java.io.BufferedInputStream)6 FileInputStream (java.io.FileInputStream)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 Properties (java.util.Properties)6 Options (org.apache.commons.cli.Options)6 PosixParser (org.apache.commons.cli.PosixParser)6