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