Search in sources :

Example 1 with RpcDecoder

use of com.jim.framework.rpc.codec.RpcDecoder in project jim-framework by jiangmin168168.

the class RpcServerInitializer method initChannel.

@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    // logger.info("RpcServerInitializer.initChannel");
    ChannelPipeline pipeline = socketChannel.pipeline();
    ;
    Executor executor = this.rpcThreadPoolFactory.getThreadPool(ConstantConfig.DEFAULT_THREAD_POOL_NAME).getExecutor(1, 1);
    pipeline.addLast(new RpcEncoder(RpcResponse.class)).addLast(new RpcDecoder(RpcRequest.class)).addLast(new IdleStateHandler(Constants.READER_TIME_SECONDS, 0, 0)).addLast(new ServerHeartbeatHandler()).addLast(new RpcServerInvoker(this.handlerMap, this.filterMap, executor));
}
Also used : RpcEncoder(com.jim.framework.rpc.codec.RpcEncoder) Executor(java.util.concurrent.Executor) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) ServerHeartbeatHandler(com.jim.framework.rpc.keepalive.ServerHeartbeatHandler) RpcDecoder(com.jim.framework.rpc.codec.RpcDecoder) RpcResponse(com.jim.framework.rpc.common.RpcResponse) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 2 with RpcDecoder

use of com.jim.framework.rpc.codec.RpcDecoder in project jim-framework by jiangmin168168.

the class RpcClientInitializer method initChannel.

@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline cp = socketChannel.pipeline();
    cp.addLast(new RpcEncoder(RpcRequest.class));
    cp.addLast(new RpcDecoder(RpcResponse.class));
    cp.addLast(new IdleStateHandler(0, 0, Constants.ALLIDLE_TIME_SECONDS));
    cp.addLast(new ClientHeartbeatHandler());
    cp.addLast(new RpcClientInvoker(this.getFilterMap()));
}
Also used : RpcEncoder(com.jim.framework.rpc.codec.RpcEncoder) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) RpcRequest(com.jim.framework.rpc.common.RpcRequest) ClientHeartbeatHandler(com.jim.framework.rpc.keepalive.ClientHeartbeatHandler) RpcDecoder(com.jim.framework.rpc.codec.RpcDecoder) RpcResponse(com.jim.framework.rpc.common.RpcResponse) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

RpcDecoder (com.jim.framework.rpc.codec.RpcDecoder)2 RpcEncoder (com.jim.framework.rpc.codec.RpcEncoder)2 RpcResponse (com.jim.framework.rpc.common.RpcResponse)2 ChannelPipeline (io.netty.channel.ChannelPipeline)2 IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)2 RpcRequest (com.jim.framework.rpc.common.RpcRequest)1 ClientHeartbeatHandler (com.jim.framework.rpc.keepalive.ClientHeartbeatHandler)1 ServerHeartbeatHandler (com.jim.framework.rpc.keepalive.ServerHeartbeatHandler)1 Executor (java.util.concurrent.Executor)1