Description
There are number of problem with OdbcNioParser which makes it usable only in single-threaded application when no TCP messages are batched together:
1) Parser is not thread-safe and hence cannot have any state like "leftToReceive" of "curMsg" fields.
Instead, you should rely on meta assigned to GridNioSession. See GridDirectParser as example.
This will make the parser thread-safe.
2) Message is decoded incorrectly. When "decode" is called, you cannot rely on buf.array(), as this array could contain multiple requests. Moreover, there are no guarantees that current message is started from the beginning of this array. So, the following line might return incorrect result:
int msgLen = reader.readInt();
Instead, you should follow common practice:
1) Always rely on ByteBuffer.remaining()
2) Read message byte-by-byte until all 4 bytes are read.
3) Then read message body into separate byte[] until all data is ready.
4) And only then you can create BinaryHeapInputStream and deserialize the stuff.