On 1/23/12 5:48 PM, Robert Tomczyk wrote:
And its happens when im using Unordered or Ordered ThreadPool

Ok, let me try to explain what MINA does under the hood :

- MINA is just a NIO framework. It does no magic, it just receives byte[] and send byte[]; - however, we have added some convenient filters to allow users to transform a data structure to byte[] (encode) and from byte[] to data structure (decode); - this transformation (encoding/decoding) is not MINA's business, you have to implement the code that does the transformation; - as the incoming byte[] can be fragmented (ie, there is no guarantee whatsoever that the bytes won't be send one byte by one byte to the remote peer), you have to deal with this fragmentation. This is only a problem on the decoder size (we don't fragment anything when we send data : we consider a message as a whole), and the only way to deal with this fragmentation is to accumulate the incomig bytes before doing the decoding of a complete message (or you have designed a decoder that can accept a non-complete PDU, and capable of building incomplete message until it received everything needed to complete it); - once a message has been fully decoded (ie we have received enough bytes to decode a full message), then MINA generates a messageReceived() event, which has to be processed in the Handler.

This is all what MINA does, and everything else around is just provided to ease some corner cases. You most certainly don't need any of them (I'm talking here about executor, demuxHandlers, and such things).

The only reasons why your code does not work are :
- there is a bug in MINA (*very* unlikely, but still possible, and if so, we would be extremely grateful to have the code that would help us reproduce the bug, in order to fix MINA)
- there is a bug in your codec or in your handler.

If we focus on the second option, then I would suggest you check carefully what you are doing in the codec. Using Wireshark could help to see what exactly is being transmitted on the wire. if the data are not what you are expecting to receive on the server (or the client), then that means you are not sending them correctly. Check the encoder and see if it does its job correctly. If you see the correct byte[] being sent, then check the decoder : you probably incorrectly decode the bytes and don't generate correctly the data structure you are expecting.

I hope I have explained clearly what MINA does and where to check for a potential error. Tell me if you need more direction.

Thanks !



--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to