MessageEvent messageEvent = (MessageEvent)e;
Object message = messageEvent.getMessage();
if(message instanceof HttpRequest) {
HttpRequest request = (HttpRequest)message;
int metricCount = processMetric(request);
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
response.setContent(ChannelBuffers.copiedBuffer("\n" + metricCount + "\n", CharsetUtil.UTF_8));
response.setHeader(CONTENT_TYPE, "text/plain");
ChannelFuture future = Channels.future(channel);
ctx.sendDownstream(new DownstreamMessageEvent(channel, future, response, channel.getRemoteAddress()));
future.addListener(ChannelFutureListener.CLOSE);
}
}