Hi, 

Then I understand why now. But I need now to correct my filterchain to let pass 
trough those empty message without processing. 
It would have nice to use an MessageWriteRequest (or NullMessageWriteRequest) 
that is not a private subclass of ProtocolCodecFilter in order to be able to 
ignore such WriteRequest. 

At the end, in the logic way that ProtocolCodecFilter performs, my filter did 
it bad : it prefix length ot any write request even with zero length byte 
buffer. 

thanks for the clarification. I will do the correction on my side. 

Adrien 

----- Mail Original ----- 
De: "Emmanuel Lecharny" <[email protected]> 
À: [email protected] 
Envoyé: Lundi 13 Septembre 2010 09h41:48 GMT +01:00 Amsterdam / Berlin / Berne 
/ Rome / Stockholm / Vienne 
Objet: Re: Mina 2.0 : ProtocolCodecFilter send two WriteRequest 


> Hello, 
> 
> 
> I have write a protocol stack with Mina and glad with the behavior of the 
> platform unless for one thing that I don't understand. 
> May be my question should be sent to developper list but I have may be not 
> understood how to deal with ProtocolCodecFilter. 
> 
> 
> The ProtocolCodecFilter discussion on mina.org was not helpful. In analyzing 
> code, I found that ProtocolCodecFilter calls the encoder to write messages 
> with ProtocolCodecOutput and just after do a WriteRequestMessage that is 
> forwarded to the filterchain with an emtpy buffer. 

yeah, this is a bloddy hack that we would like to get rid of in the near 
future... Let me explain further ... 
> // Now we can try to encode the response 
> encoder.encode(session, message, encoderOut); 
> 
> // Send it directly 
> ((ProtocolEncoderOutputImpl)encoderOut).flushWithoutFuture(); 
> 
> // Call the next filter 
> nextFilter.filterWrite(session, new MessageWriteRequest( writeRequest)); 
> 
> Moreover, " messageSent" method forward MessageWriteRequest but not others. 
> 
> 
> That should not disturb some people but I think it is annoying for two 
> reasons : 
> - ProtocolFilterCodec forks an unwanted message (or it is needed but I am not 
> aware of it) 
> - It does have impact to the filterchain and normal protocol design permits 
> total independance of one level of the stack (some filter in the 
> filterchain). 
> 
> 
> I deal with it in adding a filter in my filterchain that do not forwards such 
> empty message to the rest of the filterchain. 
> Did I made it wrong ? 
The empty message is used to count the number of sent messages. It's 
used for statistic purposes. As we have no way to know that a full 
message has been sent in the low level layers of mina, because it just 
deals with byte[], sending a empty buffer is a way to tell this ayer 
'hey, ok, the message has been completely sent'. In any case, this empty 
message is *never* sent to the other side (ie, the client) because it's 
empty. 

Ok, I know, not very beautiful... 
> 
> Cheers, 
> 
> 
> Adrien 


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

Reply via email to