Le 17/07/2014 10:00, Rok Meznarič a écrit : > Hello, > I have a question about mina messageReceived. I have a server that > accepts requests from clients. It can happen that a client spams my server > with Requests that take some time to take the needed work. > It can happen that a client gets disconnected, how can I now discarge the > Requests that were send from the client, but didnt get in time into > "messageReceived" ?? is there any option for > session.readMessageQueue.clear/clean ???? So can I manualy clear the > requests that are waiting in the mina session to be proced ??? Session > close doesnt make it happen, sadly.
Have you tried close( true ) ? This should discard all the messages in the session queue. > > My second question is, can I get somehow the size of the mina > messageReceive queue size out '? That does not make a lot of sense. We don't stack incoming messages : we push them immediately into the processing chain. What could happen though is that either you received more than one message (keep in mind that the socket does not have any clue about a message, it just receives bytes. If the remote peer has pushed many messages, it may be possible that you just get all of them with one simple read. In this case, we iterate through all the read messages). or you have added a ExecutorFilter - or any pool of thread of yours - iin the chain. In this case, yes, messages could be stacked, but there is little MINA can do about that, it's up to you to deal with such a stack of message. Last, not least, if your client disconnect (cleanly, which means you get a sessionClosed event), then you can most certainly set a flag refelcting this status, and use this flag in your handler messageReceived() method. If teh client brutally disconnected (pulling out the cable, for instance), there is little you can do. Hope it helps...
