Hi Alimli,

On 7/27/07, alimli <[EMAIL PROTECTED]> wrote:
> My question is about overriding IoHandlerAdapter's messageReceived method.
> Is it safe to run long running actions in this method such as
> session.write().join(5000)?
> Will there be a scalability penalty?

If you are running a long-running task, you need to insert an
ExecutorFilter.  Please refer to our 'Configuring Thread Model'
tutorial for more detailed information.

And, if your client sends messages asynchronously (i.e. sends requests
before all previous responses are received.), any incoming messages
will be buffered in the internal queue until your messageReceived()
method returns.  The queue is maintained on a per-session basis, so
any other sessions won't be affected when one session's
messageReceived() runs long.

> Actually, what confuses my mind is that we create only one instance of our
> IoHandlerAdapter implementation. When multiple messages are received
> concurrently, all these messageReceived's can be called concurrently with
> single instance. For clarity, I don't want to use any shared variable but
> only variables local to messageReceived.

You can store per-session data as session attributes.  Please take a
look at IoSession.get/setAttribute() methods.

> Also, I'll be very glad if your offer some resource for developing my java
> concurency knowledge.

I'd suggest you to read 'Java Concurrency in Practice'.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to