Event order and synchronization
Marc-André Laverdière
marcandre.laverdiere at gmail.com
Tue Aug 24 00:26:01 EDT 2010
There is a handler that guarantees event order. That is the advisable way to
go.
On 22 Aug 2010 14:56, "McCloud" <Duncan.Doyle at gmail.com> wrote:
Hello,
I'm trying to write a webservices monitor using a proxy build in Netty. I'm
using the Proxy example as a base. While figuring out Netty and its
internals (I like to know how stuff works), I came across this forum thread
which confused me with regards to setting ' 'setReadable(false)' on a
Channel and the order of events (channelOpen, messageReceived):
http://www.jboss.org/netty/community.html#nabble-td4075899|a4797193
In this thread it is stated that, when bytes are read before
'setReadable(false)' has been called, you will receive a 'messageReceived'
event (which is as expected). Now I was wondering, as Netty is asynchronous,
if it is possible that you get a 'messageReceived' event before the
'channelOpen' method has completely finished? If that is possible, looking
at the Proxy InboundHandler example
(
http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/proxy/HexDumpProxyInboundHandler.html
),
you could get into a situation in which you write to an outboundChannel
which is still 'null' or which is not connected.
While Netty seems to use a single worker thread per connection, I guess that
this is not possible (the InboundHandler is used by only on thread, so you
can't execute methods concurrently on the same InboundHandler object), but
then there seems to be another problem with the example code. What happens
when bytes have been read before 'setReadable(false)' has been called and
the outbound connection can not be made (in the ' channelOpen' method)? I
guess that 'messageReceived' will be called which tries to write to an
outboundChannel which is not connected. So, shouldn't the 'messageReceived'
method in the example check whether the outboundChannel is actually open for
writing?
Just some questions so I won't run into strange concurrency bugs :-)
Cheers,
Duncan
--
View this message in context:
http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Event-order-and-synchronization-tp5449312p5449312.html
Sent from the Netty User Group mailing list archive at Nabble.com.
_______________________________________________
netty-users mailing list
netty-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/netty-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100824/8701a37f/attachment.html
More information about the netty-users
mailing list