Hi,
the best way to check - is to write a test ;)
WBR,
Alexey.
On Nov 24, 2008, at 21:32 , Survivant 00 wrote:
> hummm.. I change my hasMoreBytesToParse method to that :
>
>
>
> public boolean hasMoreBytesToParse() {
>
> if(s_logger.isDebugEnabled()){
> s_logger.debug("hasMoreBytesToParse");
> }
>
> // I added this validation
> if (eoqFound && processingBuffer!=null &&
> processingBuffer.hasRemaining()){
> return true;
> }
>
> return eoqFound && processingBuffer != null &&
> processingBuffer.position() > 0;
> }
>
>
> it fix the problem.. I obtain all the queries now..
>
> but I'm scared.. did I fix the problem or it's a patch that can
> explode anytime ?
>
>
> here the output to see if the order of calls are right
>
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> startBuffer
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage: quote|99|bce;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|nt;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|abx;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> msg=quote|99|bce;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|
> 99|nt;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|
> abx;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> index: 53 substr: quote|99|nt;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|abx;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq] substr.len: 232
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> getNextMessage
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.connection.handler.filter.QuoteQueryManagerFilter)
> - Query = quote|99|bce;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> add item=quote|99|bce;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> took item=quote|99|bce;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage: quote|99|nt;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|abx;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> msg=quote|99|nt;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|
> 99|abx;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|
> aaa;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|
> cdcd;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> index: 52 substr: quote|99|abx;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq] substr.len: 175
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> getNextMessage
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.connection.handler.filter.QuoteQueryManagerFilter)
> - Query = quote|99|nt;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> add item=quote|99|nt;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage: quote|99|abx;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> msg=quote|99|abx;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|
> 99|aaa;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|
> cdcd;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> index: 53 substr: quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq] substr.len: 117
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> getNextMessage
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.connection.handler.filter.QuoteQueryManagerFilter)
> - Query = quote|99|abx;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> add item=quote|99|abx;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage: quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> msg=quote|99|aaa;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|
> 99|cdcd;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> index: 53 substr: quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq] substr.len: 59
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> getNextMessage
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.connection.handler.filter.QuoteQueryManagerFilter)
> - Query = quote|99|aaa;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> add item=quote|99|aaa;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage: quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> msg=quote|99|cdcd;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> index: 54 substr: substr.len: 0
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> getNextMessage
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.connection.handler.filter.QuoteQueryManagerFilter)
> - Query = quote|99|cdcd;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> add item=quote|99|cdcd;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> releaseBuffer
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> startBuffer
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 15:27:32]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> releaseBuffer
> DEBUG [24/11/08 15:27:32] (com.gfbn.quotegw.command.QuoteCommand) -
> QuoteQuery received=quote|99|bce;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE,
> took item=quote|99|nt;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32] (com.gfbn.quotegw.command.QuoteCommand) -
> QuoteQuery received=quote|99|nt;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE,
> took item=quote|99|abx;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32] (com.gfbn.quotegw.command.QuoteCommand) -
> QuoteQuery received=quote|99|abx;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE,
> took item=quote|99|aaa;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32] (com.gfbn.quotegw.command.QuoteCommand) -
> QuoteQuery received=quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE,
> took item=quote|99|cdcd;can;;t|SYMBOL,PRICE_LAST,PRICE_LAST_DATE
> DEBUG [24/11/08 15:27:32] (com.gfbn.quotegw.command.QuoteCommand) -
> QuoteQuery received=quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE,
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.response.handler.QuoteResponseHandler) - SENDING
> QUOTE TO CLIENT = 1099 SYMBOL 7 6
> ca;BCE1099 PRICE_LAST 3 4 38.01099
> PRICE_LAST_DATE 6 19 2008/11/24 15:27:302
> 99 7 15 4-End of record2
> 99 7 17 3-End of response
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.response.handler.QuoteResponseHandler) - SENDING
> QUOTE TO CLIENT = 1099 SYMBOL 7 5
> ca;NT1099 PRICE_LAST 3 4 0.521099
> PRICE_LAST_DATE 6 19 2008/11/24 15:27:062
> 99 7 15 4-End of record2
> 99 7 17 3-End of response
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.response.handler.QuoteResponseHandler) - SENDING
> QUOTE TO CLIENT = 1099 SYMBOL 7 6
> ca;ABX1099 PRICE_LAST 3 4 35.71099
> PRICE_LAST_DATE 6 19 2008/11/24 15:27:242
> 99 7 15 4-End of record2
> 99 7 17 3-End of response
> DEBUG [24/11/08 15:27:32]
> (com.gfbn.quotegw.response.handler.QuoteResponseHandler) - SENDING
> QUOTE TO CLIENT = 1099 SYMBOL 7 6
> ca;AAA1099 PRICE_LAST 3 4 0.051099
> PRICE_LAST_DATE 6 19 2008/11/23 19:00:002
> 99 7 15 4-End of record2
> 99 7 17 3-End of response
>
>
> 2008/11/24 Survivant 00 <survivant00_at_gmail.com>
> I have a problem. I was able to parse incoming requests with
> incomplete requests (the incomplete request, will be parse in the
> next pass). If the ByteBuffer contains 1 request + 1 incomplete,
> the next pass will parse the incomplete request.. no problem there..
>
> but now.. I did a test.. I sent 3 query in the same requests.
>
> like
>
> aaa|BID[EOQ]bbb|BID[EOQ]ccc|BID[EOQ]
>
> my parser return the first query in getMessage(), but because the
> server doesn't receive more datas, it doesn't do a next pass and it
> stuck with 2 query in the BB.
>
>
> here the flow
>
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> startBuffer
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasNextMessage: quote|99|bce;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|nt;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|abx;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|aaa;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]quote|99|cdcd;can;;t|
> SYMBOL,PRICE_LAST,PRICE_LAST_DATE[eoq]
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> msg=aaa|BID[EOQ]bbb|BID[EOQ]ccc|BID[EOQ]
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> getNextMessage
> DEBUG [24/11/08 14:44:46]
> (com.gfbn.quotegw.connection.handler.filter.QuoteQueryManagerFilter)
> - Query = aaa|BID
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> releaseBuffer
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> startBuffer
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 14:44:46]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> releaseBuffer
> DEBUG [24/11/08 14:44:51]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> isExpectingMoreData
> DEBUG [24/11/08 14:44:51]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> startBuffer
> DEBUG [24/11/08 14:44:51]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> hasMoreBytesToParse
> DEBUG [24/11/08 14:44:51]
> (com
> .gfbn.quotegw.connection.handler.parser.QuoteQueryProtocolParser) -
> releaseBuffer
>
>
> I didn't detect that in my demo with Grizzly. You can browse the
> source code of the parser there
> https://grizzly.dev.java.net/source/browse/grizzly/trunk/samples/framework/nio-migration-guide/demo3/src/main/java/com/sun/grizzly/samples/migration/connection/handler/parser/QuoteQueryProtocolParser.java?rev=1836&view=markup
>
>
>
>
>