netty应用程序中的请求和响应之间的延迟

时间:2015-07-28 17:18:25

标签: java httprequest netty

我有一个扩展SimpleChannelInboundHandler<HttpRequest>的处理程序。在发送特定请求的响应之前需要延迟一段时间,我将使用方法channelRead0(ChannelHandlerContext ctx, HttpRequest msg)中的下一个代码:

ctx.executor().schedule(() -> ctx.write(response), 3, TimeUnit.SECONDS);

但它不起作用。我做错了什么,我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

我认为您需要将其更改为:

ctx.executor().schedule(() -> ctx.writeAndFlush(response), 3, TimeUnit.SECONDS);
相关问题