Hi everyone! I'm new to Mina and I found it very interesting. I've some
questions related to CumulativeProtocolDecoder and messages delimited by
CRLF.

Here is the situation: I've got to connect to a socket where I receive text
messages from (I'm a client), this is how I configure my client:
        SocketConnectorConfig cfg = new SocketConnectorConfig();
        cfg.setConnectTimeout(30);
        cfg.getFilterChain().addLast(
                "CODEC", new ProtocolCodecFilter(new OWNCodecFactory()));
(1)
        int n = this.connProps.getConnectAttempts();
        SocketAddress addr = new InetSocketAddress(
                connProps.getHost(), 
                connProps.getPort());
        
(1) OWNCodecFactory is an extension of DemuxingProtocolCodecFactory, where I
add my encoders and decoders.

At this point there's no problem, I can connect to the socket and read
messages from it. The problems begins when the sockets sends more than one
text message in the same writting (messages are delimited by a CRLF), here
are some examples:

Message one: MESSAGE_TEXT<CR><LF>
Message two: MESSAGE_TEXT<CR><LF>MESSAGE_TEXT2<CR><LF>

I have to split the buffer into several messages and process them. At first
point I thought of an extension of CumulativeProtocolDecoder (because I need
the 'cumulative' functionality) that splits the ByteBuffer into several
chunks (one per message) and does exactly the same thing as
CumulativeProtocolDecoder, but with every chunk of the ByteBuffer received.
Once I have the message splitted and decoded I have to make them get to my
implementation of an IoHandlerAdapter to do some business logic. 
These are my questions:
a) Is this clear enough? ;) - apologies for my english
b) Is this a good aproach?
c) Is there a better and transparent way to do such a thing (first decoding
to split messages, and then process them)?
d) What if one of the decoders fails and throws an exception? I need to
process all messages independently

Thanks in advance,
Gustavo


-- 
View this message in context: 
http://www.nabble.com/CumulativeProtocolDecoder-with-messages-delimited-by-CRLF-tf3965652.html#a11255508
Sent from the mina dev mailing list archive at Nabble.com.

Reply via email to