You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Zohar Amir <zo...@gmail.com> on 2006/03/26 16:46:10 UTC

what should I use? - please help

Hello,
I'm building a server to serve my clients and I'm facing some problems
(again).
Each message in my protocol is composed of a PDU that holds an XML content.
Clients may send an arbitrary number of messages at once (that may be
contained in a single TCP packet). When using IoHandler and a
ProtocolDecoder there is no way to produce more than a single message object
(written to the ProtocolDecoderOutput). I can define a "MegaMessage" that
can contain more than one of my messages and then handle this within the
IoHandler.messageReceived method, but I wonder whether there's a better way
of doing this - Is there?
Another issue is that messages may be received in parts (due to network
latency or other network behavior). What is the best way to handle this
behavior? If the solution is using StreamIoHandler then there is an issue
that I still need to report to JIRA, regarding Exception handling of socket
closure (will do that shortly).
Thanks,
Zohar.

Re: what should I use? - please help

Posted by Trustin Lee <tr...@gmail.com>.
Sorry fot not responding to your message so far.  I was just slipped out by
mistake.

On 3/26/06, Zohar Amir <zo...@gmail.com> wrote:
>
> Hello,
> I'm building a server to serve my clients and I'm facing some problems
> (again).
> Each message in my protocol is composed of a PDU that holds an XML
> content.
> Clients may send an arbitrary number of messages at once (that may be
> contained in a single TCP packet). When using IoHandler and a
> ProtocolDecoder there is no way to produce more than a single message
> object
> (written to the ProtocolDecoderOutput). I can define a "MegaMessage" that
> can contain more than one of my messages and then handle this within the
> IoHandler.messageReceived method, but I wonder whether there's a better
> way
> of doing this - Is there?


You can write multiple times, and it generates more than one messageReceived
events.

Another issue is that messages may be received in parts (due to network
> latency or other network behavior). What is the best way to handle this
> behavior? If the solution is using StreamIoHandler then there is an issue
> that I still need to report to JIRA, regarding Exception handling of
> socket
> closure (will do that shortly).


My suggestion is to use DemuxingProtocolCodecFactory. SumUp example
demonstrates this codec.

If your codec is simple enough, you could use CumulativeProtocolDecoder,
too.

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6