Dear Emmanuel,

Thanks for prompt reply. Please see my comments inline.


Best Regards,
Vishal

-----Original Message-----
From: Emmanuel Lecharny [mailto:elecha...@gmail.com] 
Sent: Thursday, October 13, 2011 12:07 PM
To: users@mina.apache.org
Subject: Re: Strange problem in reading the data on socket in ProtocolDecoder


On 10/13/11 6:58 AM, Vishal Gupta wrote:
> ====================
> Scenraio:
> ====================
> - A server is sending data to the MINA server which has implemented
> "CumulativeProtocolDecoder"
> - Server is sending x bytes
> - While getting data first thread is getting data from position m instead of
> position 0
In the decoder ? If the data has just been received, then the data 
should be at position 0. If it's not the case, then somewhere in your 
code, you are reading the IoBuffer, moving the position.
> - Second thread picks the data from 0 to m
Probably because the first buffer has been fully read.
> - Either of the thread doesn't get the complete data and that's why protocol
> decoding is failed
Without the complete decoder code, it's hard to tell what's going wrong.

In any case, there is something wrong in your code.

[Vishal] Decoder code can sure be suspected, but the logs what I have sent is 
indicating the data received in decode function at entry(before decoding has 
even started) and there are two threads picking up the data (partially 
each)....this is the main problem for which decoder has not yet in picture.

(2011-10-12 
14:18:01,039)(pool-3-thread-44)(DEBUG)(IoFilterEvent.java)(fire)(118)--Event 
MESSAGE_RECEIVED has been fired for session 35
(2011-10-12 
14:18:04,589)(pool-3-thread-45)(DEBUG)(IoFilterEvent.java)(fire)(69)--Firing a 
MESSAGE_RECEIVED event for session 35
(2011-10-12 
14:18:04,590)(pool-3-thread-44)(INFO)(LoggingFilter.java)(log)(141)--RECEIVED: 
HeapBuffer[pos=0 lim=86 cap=256: 10 09 00 00 10 10 00 00 10 11 00 00 10 12 00 
00...] 
(2011-10-12 
14:18:04,589)(pool-3-thread-45)(INFO)(LoggingFilter.java)(log)(141)--RECEIVED: 
HeapBuffer[pos=0 lim=128 cap=128: 00 D4 60 07 92 80 88 00 CD 01 01 60 07 92 00 
00...]


> - Data is coming correctly to the socket as confirmed by "tcpdump logs"
> - Something which is I am doing wrong or has to be taken care of? How do I
> guarantee the only one thread picks up the data and in right order??
It's guaranteed. The thing is that you have to take care of split 
messages ( it can be received in many parts, thus the use of the 
CumulativeProtocolDecoder). OTOH, you have to b careful in the way you 
handle the parts, to form a complete message. Again, the ecoder code is 
necessary.

 [Vishal] That’s not happening as per the logs, there is definitely 2 threads 
who have picked the data, first one picking the later portion and second one 
picking the former(confirmed using the time stamp, and message received event). 
Code is working fine with partial data(split messages) coming on sequential 
basis on same thread/session. --------PLEASE CONFIRM------However one thing I 
might be doing wrong is adding "threadPool" filter before adding "codec".

> - Sorry for being little verbose, but thought it might help to give max info
> in problem statement
No, this is perfect.


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


Reply via email to