Stefano Bagnara wrote:
Emmanuel Lecharny ha scritto:
Hi Stefano,

what about storing a delay and a dateOflastmessage in the session ? When you receive a new message on the same session, you compare the current date with the dateOflastmessage+delay, if it's >, you process the message, otherwise, you just sleep for a portion of the delay.

Would it be ok ?

How do I sleep in order to block the processing for that specific session but continue the processing of messages for all of the other sessions?
Hmmmm... If you sleep, you are freezing a thread. Yep, that's not a good solution, true.

From my understanding if I do a Thread.sleep() the whole mina processing will sleep so no other session will continue its conversation.
Not exactly, because you will pick a thread in an executor to process the incoming request. But the problem remains, because if you sleep, you freeze this thread, and this could lead to a starvation at some point.

This would change if I have a pool of executors, but anyway if I have 3 executors and 3 sessions sleeping the whole processing will be blocked...

Is this correct?
I think so.

I'm trying to mis it with your continuation stuff, which looks like much more promising to address such a problem. In this case, we will need a scheduler to 'continue' the processing of the wating requests when the delay has expired.

There is something interesting we might really want to implement, that's for sure !

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to