Thanks, that's helpful. I was most interested in (3), a stateful Handler that's created per-channel with no ExecutionHandler. It sounds like in this case I can assume that there will only be one outstanding Channel event at a time, and that all events will happen in order. That makes sense; keeping state right in a per-channel, stateful handler would get complicated if events could happen simultaneously. <br>
<br>Are there any visibility guarantees across invocations of Handlers? E.g. if I handle an event in my per-Channel handler and change a member variable of the Handler, will that change be visible when the same Handler instance is invoked for the next event in a different thread? <br>
<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Date: Sun, 18 Oct 2009 00:37:46 -0700 (PDT)<br>
From: Frederic Bregier <<a href="mailto:fredbregier@free.fr">fredbregier@free.fr</a>><br>
Subject: Re: Simultaneous invocation of handlers<br>
To: <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
Message-ID: <<a href="mailto:1255851466682-3843496.post@n2.nabble.com">1255851466682-3843496.post@n2.nabble.com</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
<br>
Hi Dan,<br>
<br>
It depends on the way you wrote your handler:<br>
<br>
1) If you create only one Handler for any connected Channel (so not using a<br>
ChannelPipelineFactory, and if using it not creating a new handler as<br>
business handler - generally the last one): then any connected channel can<br>
send a message and thus giving two messageReceived calls at the same time,<br>
except if an OrderedMemoryAwareThreadPoolExecutor is added in the pipeline.<br>
<br>
2) If you have one handler by channel but using a<br>
MemoryAwareThreadPoolExecutor, then for one client, if two sends occur, it<br>
may lead to two messageReceived at the same time (note the "may" since I'm<br>
not totally sure, what I'm sure is that message can arrive in any order like<br>
the API says).<br>
<br>
3) If you have one handler by channel and you don't use any<br>
MemoryAwareThreadPoolExecutor or if one is used it is the Ordered one, then<br>
message will arrived in order and one by one for this handler (= one<br>
channel). (Note that the OrderedMemoryAwareThreadPoolExecutor is not<br>
necessary to get this behaviour).<br>
<br>
4) If you have an handler shared among all connected channel but you use a<br>
OrderedMemoryAwareThreadPoolExecutor in the pipeline before this handler,<br>
then the order is respected for at least one channel, but still two channels<br>
can received each one a message at the same time.<br>
<br>
So first it depends on if your logic is to have one handler for all channel,<br>
or one handler by channel.<br>
Then try to follow those guidelines (note they are not official, just mines,<br>
they surely exist other ways ;-)<br>
<br>
Cheers,<br>
Frederic<br>
<br>
<br>
Dan D wrote:<br>
><br>
> Say I've got a ChannelHandler that acts upstream of the the HTTP code<br>
> handlers. Within messageReceived() I'm handling an HTTP request. While<br>
> I'm in messageReceived(), can messageReceived be invoked *for the same<br>
> Channel* in another thread (a pipelined HTTP request comes in on the same<br>
> connection while I'm still processing the first one)? Or will the second<br>
> messageReceived() not be invoked until the first completes?<br>
><br>
> Thanks.<br>
><br>
> _______________________________________________<br>
> netty-users mailing list<br>
> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
><br>
><br>
<br>
<br>
-----<br>
Hardware/Software Architect<br>
--<br>
View this message in context: <a href="http://n2.nabble.com/Simultaneous-invocation-of-handlers-tp3842471p3843496.html" target="_blank">http://n2.nabble.com/Simultaneous-invocation-of-handlers-tp3842471p3843496.html</a><br>
Sent from the Netty User Group mailing list archive at Nabble.com.<br>
<br><br></blockquote></div>