1. public class ProtoBufClientHandler extends ChannelInboundHandlerAdapter {
    2. @Override
    3. public void channelActive(ChannelHandlerContext ctx) {
    4. System.out.println("Prepare to make data........");
    5. PersonProto.Person.Builder builder = PersonProto.Person.newBuilder();
    6. builder.setName("Mark");
    7. builder.setId(1);
    8. builder.setEmail("Mark@enjoyedu.com");
    9. System.out.println("send data........");
    10. ctx.writeAndFlush(builder.build());
    11. }
    12. @Override
    13. public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    14. cause.printStackTrace();
    15. ctx.close();
    16. }
    17. }