Bharat Bhansali
Bharat Bhansali

Reputation: 1

Replacement for netty SimpleChannelUpstreamHandler from netty 3 to 4.1

We are upgrading from netty 3 to 4.1 and have lot of code which uses SimpleChannelUpstreamHandler. What is the replacement for this class and its method messageReceived? below is code snippet.

public class IcapClientHandler extends SimpleChannelUpstreamHandler {

public class IcapClientHandler extends SimpleChannelUpstreamHandler {

   @Override
   public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
      IcapResponse response = (IcapResponse)e.getMessage();
      if(response.getStatus().equals(IcapResponseStatus.CONTINUE)) {
         System.out.println(response.toString());
           IcapChunk chunk = new DefaultIcapChunk(ChannelBuffers.copiedBuffer("ns why and how we can avoid such a desaster next time...".getBytes()));
           IcapChunkTrailer trailer = new DefaultIcapChunkTrailer(true,false);
           ctx.getChannel().write(chunk);
           ctx.getChannel().write(trailer);
      } else if(response.getStatus().equals(IcapResponseStatus.NO_CONTENT)) {
         System.out.println(response.toString());
      }
   }
}

Tried referring ChannelInboundHandlerAdapter in Netty 4.1 but it does not have any corresponding method for messageReceived.

Upvotes: 0

Views: 206

Answers (1)

needmorecode
needmorecode

Reputation: 11

This method has been replaced with channelRead in ChannelHandler.

You can look to https://netty.io/wiki/new-and-noteworthy-in-4.0.html for details.

Upvotes: 0

Related Questions