<p>There is a handler that guarantees event order. That is the advisable way to go.</p>
<p><blockquote type="cite">On 22 Aug 2010 14:56, &quot;McCloud&quot; &lt;<a href="mailto:Duncan.Doyle@gmail.com">Duncan.Doyle@gmail.com</a>&gt; wrote:<br><br><br>
Hello,<br>
<br>
I&#39;m trying to write a webservices monitor using a proxy build in Netty. I&#39;m<br>
using the Proxy example as a base. While figuring out Netty and its<br>
internals (I like to know how stuff works), I came across this forum thread<br>
which confused me with regards to setting &#39; &#39;setReadable(false)&#39; on a<br>
Channel and the order of events (channelOpen, messageReceived):<br>
<a href="http://www.jboss.org/netty/community.html#nabble-td4075899|a4797193" target="_blank">http://www.jboss.org/netty/community.html#nabble-td4075899|a4797193</a><br>
<br>
In this thread it is stated that, when bytes are read before<br>
&#39;setReadable(false)&#39; has been called, you will receive a &#39;messageReceived&#39;<br>
event (which is as expected). Now I was wondering, as Netty is asynchronous,<br>
if it is possible that you get a &#39;messageReceived&#39; event before the<br>
&#39;channelOpen&#39; method has completely finished? If that is possible, looking<br>
at the Proxy InboundHandler example<br>
(<a href="http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/proxy/HexDumpProxyInboundHandler.html" target="_blank">http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/proxy/HexDumpProxyInboundHandler.html</a>),<br>

you could get into a situation in which you write to an outboundChannel<br>
which is still &#39;null&#39; or which is not connected.<br>
<br>
While Netty seems to use a single worker thread per connection, I guess that<br>
this is not possible (the InboundHandler is used by only on thread, so you<br>
can&#39;t execute methods concurrently on the same InboundHandler object), but<br>
then there seems to be another problem with the example code. What happens<br>
when bytes have been read before &#39;setReadable(false)&#39; has been called and<br>
the outbound connection can not be made (in the &#39; channelOpen&#39; method)? I<br>
guess that &#39;messageReceived&#39; will be called which tries to write to an<br>
outboundChannel which is not connected. So, shouldn&#39;t the &#39;messageReceived&#39;<br>
method in the example check whether the outboundChannel is actually open for<br>
writing?<br>
<br>
Just some questions so I won&#39;t run into strange concurrency bugs :-)<br>
<br>
Cheers,<br>
<br>
Duncan<br>
<font color="#888888">--<br>
View this message in context: <a href="http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Event-order-and-synchronization-tp5449312p5449312.html" target="_blank">http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Event-order-and-synchronization-tp5449312p5449312.html</a><br>

Sent from the Netty User Group mailing list archive at Nabble.com.<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>
</font></blockquote></p>