Simultaneous invocation of handlers

Frederic Bregier fredbregier at free.fr
Sun Oct 18 03:37:46 EDT 2009


Hi Dan,

It depends on the way you wrote your handler:

1) If you create only one Handler for any connected Channel (so not using a
ChannelPipelineFactory, and if using it not creating a new handler as
business handler - generally the last one): then any connected channel can
send a message and thus giving two messageReceived calls at the same time,
except if an OrderedMemoryAwareThreadPoolExecutor is added in the pipeline.

2) If you have one handler by channel but using a
MemoryAwareThreadPoolExecutor, then for one client, if two sends occur, it
may lead to two messageReceived at the same time (note the "may" since I'm
not totally sure, what I'm sure is that message can arrive in any order like
the API says).

3) If you have one handler by channel and you don't use any
MemoryAwareThreadPoolExecutor or if one is used it is the Ordered one, then
message will arrived in order and one by one for this handler (= one
channel). (Note that the OrderedMemoryAwareThreadPoolExecutor is not
necessary to get this behaviour).

4) If you have an handler shared among all connected channel but you use a
OrderedMemoryAwareThreadPoolExecutor in the pipeline before this handler,
then the order is respected for at least one channel, but still two channels
can received each one a message at the same time.

So first it depends on if your logic is to have one handler for all channel,
or one handler by channel.
Then try to follow those guidelines (note they are not official, just mines,
they surely exist other ways ;-)

Cheers,
Frederic


Dan D wrote:
> 
> Say I've got a ChannelHandler that acts upstream of the  the HTTP code
> handlers.   Within messageReceived() I'm handling an HTTP request.  While
> I'm in messageReceived(), can messageReceived be invoked *for the same
> Channel* in another thread (a pipelined HTTP request comes in on the same
> connection while I'm still processing the first one)? Or will the second
> messageReceived() not be invoked until the first completes?
> 
> Thanks.
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
> 
> 


-----
Hardware/Software Architect
-- 
View this message in context: http://n2.nabble.com/Simultaneous-invocation-of-handlers-tp3842471p3843496.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list