Question

I have implemented a channel handler for handling http pipelining. My code is at github: https://github.com/huntc/netty-http-pipelining

My question is around the approach that I have taken and whether it is a reasonable one in the context of Netty's architecture.

When my HttpPipeliningHandler receives an upstream HttpRequest it then forms a new message event of type OrderedUpstreamMessageEvent. This event is also part of my package and retains information in relation to the request that will be required when formulating reply messages.

When a channel handler further upstream receives the OrderedUpstreamMessageEvent it forms a reply by generating a OrderedDownstreamMessageEvent e.g.:

ctx.sendDownstream(new OrderedDownstreamMessageEvent(oue, somemessage));

where

ctx = ChannelHandlerContext instance
oue = OrderedUpstreamMessageEvent instance
somemessage = some message instance to be sent as an http response

You can also do more fun stuff like send chunked replies.

Does this approach look reasonable? It certainly works! Is it regular/acceptable to transform message events in an upstream handler? Obviously if the message event is transformed again then the pipelining functionality will not work.

No correct solution

OTHER TIPS

I had a quick look... A few comments.

1) Your access of PriorityQueue must be synchronized as the downstream event may be fired by any thread.

2) Same needs to be done for nextRequiredSequence or use AtomicInteger which should be better

3) You want to use Channel.close()

The rest looks good

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top