<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, "McCloud" <<a href="mailto:Duncan.Doyle@gmail.com">Duncan.Doyle@gmail.com</a>> wrote:<br><br><br>
Hello,<br>
<br>
I'm trying to write a webservices monitor using a proxy build in Netty. I'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 ' 'setReadable(false)' 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>
'setReadable(false)' has been called, you will receive a 'messageReceived'<br>
event (which is as expected). Now I was wondering, as Netty is asynchronous,<br>
if it is possible that you get a 'messageReceived' event before the<br>
'channelOpen' 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 'null' 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'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 'setReadable(false)' has been called and<br>
the outbound connection can not be made (in the ' channelOpen' method)? I<br>
guess that 'messageReceived' will be called which tries to write to an<br>
outboundChannel which is not connected. So, shouldn't the 'messageReceived'<br>
method in the example check whether the outboundChannel is actually open for<br>
writing?<br>
<br>
Just some questions so I won'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>