When do I need to use ExecutionHandler + OrderedMemoryAwareThreadPoolExecutor

javadevmtl java.dev.mtl at gmail.com
Wed Jul 21 16:53:23 EDT 2010


Well you would want to use the ExecutionHandler when your "business" handler
needs to run in parallel and/or has long execution.

For instance my business handler has a DB connection and averages 3 seconds.
So If I need to send 2 requests to the server I would need to have 2
separate business handlers executed, without blocking the rest of the
pipeline.

For MemoryAware vs OrderedMemoryAware...

If the protocol is designed where 1 connection equals 1 request 1 response
then it doesn't matter. What I mean by this is the client opens 1 connection
sends 1 request, the server processes and responds and the connection is
closed.

Where it matters is when you start pooling/sharing connections. I.e: The
client opens 1 connection sends x amount of messages, the server receives x
messages and responds. The connection stays open until it is no longer
needed. I.e: The client logs out

For example the client opens 1 connection to the server and sends 5
different requests lets call it the Bob protocol. So the client individually
sends "Hello "My" "Name" "Is" "Bob". If you are just using MemoryAware then
your business handler may receive each individual request randomly as such:
"Bob" "Hello" "My" "Is" "Name". If for your protocol the order of the
received message is not important then it's slightly faster to use
MemoryAware. If you need order for your protocol then you use
OrderedMemoryAware.


-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/When-do-I-need-to-use-ExecutionHandler-OrderedMemoryAwareThreadPoolExecutor-tp5321786p5322885.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list