I have a typical netty server setup just a bit confused on the “proper” way to implement or rather add an OrderedMemoryAwareThreadPoolExecutor to a pipelinefactory for specific types of requests. For most requests the typical NIO request/response is fine. However for a specific type of request I’d like to use traditional threaded I/O (ala OMATPE) because of the potential for it being a long running request. What I’m doing now is parsing the URI to get the specific type of request. Short requests will be processed normally and requests of type “/long/running/request” I continue to send upstream which passes through an OMATPE which is then passed to an appropriate handler. Is this the way to go? The pipeline looks something like the following:
public ChannelPipeline getPipeline() {
return Channels.pipeline(
new HttpMessageEncoder(),
new HttpMessageDecoder(),
new shortLivedRequestHandler(),
executionHandler,
new longLivedRequestHandler());
}
In the ‘shortLivedRequestHandler’ those URI’s matching a “short-lived” regex will be processed and then sent downstream. If those URI’s happend to match a “long-lived” regex then we pass upstream to the “longLivedRequestHandler” which will in theory process in a non-blocking I/O thread and send response downstream when done.
You can try not using OMATPE and manually configuring and using your own ThreadPool.
Hope this helps.