You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by jian wu <he...@gmail.com> on 2006/10/28 20:16:10 UTC

ProtocolEncoder/Decoder v.s. MessageEncoder/Decoder

Hi,

Mina provides two types of classes for encoding/decoding protocol data:
ProtocolEncoder/ProtocolDecoder, and MessageEncoder/MessageDecoder.

Is there any guideline or recommendation when to use them?

In my perticular use case, I'm looking into decoding and encoding a
protocol data with fixed start delimiter and end delimiter but length
could be varied due to internal data structure.

Any suggestion would be really appreciated.

Thanks,

Jian

Re: ProtocolEncoder/Decoder v.s. MessageEncoder/Decoder

Posted by jian wu <he...@gmail.com>.
Hi Trustin,

> If you are implementing a complex protocol, I'd prefer
> MessageEncoder/Decoder/DemuxingProtocolCodecFactory. Sumup
> server is a good example which uses DemuxingProtocolCodecFactory.
>
Thanks a lot for the tips! I'll definitely look into it.

Best regards,

Jian

On 10/30/06, Trustin Lee <tr...@gmail.com> wrote:
> Hi Jian,
>
> On 10/29/06, jian wu <he...@gmail.com> wrote:
> >
> > Mina provides two types of classes for encoding/decoding protocol data:
> > ProtocolEncoder/ProtocolDecoder, and MessageEncoder/MessageDecoder.
>
>
> MessageEncoder and MessageDecoder are assembled into ProtocolCodecFatory by
> DemuxingProtocolCodecFactory.  The main difference is that
>
> * ProtocolEncoder and Decoder transforms all messages for a protocol.
> * MessageEncoder and Decoder transforms an individual message.
>
> If you are implementing a complex protocol, I'd prefer
> MessageEncoder/Decoder/DemuxingProtocolCodecFactory.  SumUp server is a good
> example which uses DemuxingProtocolCodecFactory.
>
> 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
>
>

Re: ProtocolEncoder/Decoder v.s. MessageEncoder/Decoder

Posted by Trustin Lee <tr...@gmail.com>.
Hi Jian,

On 10/29/06, jian wu <he...@gmail.com> wrote:
>
> Mina provides two types of classes for encoding/decoding protocol data:
> ProtocolEncoder/ProtocolDecoder, and MessageEncoder/MessageDecoder.


MessageEncoder and MessageDecoder are assembled into ProtocolCodecFatory by
DemuxingProtocolCodecFactory.  The main difference is that

* ProtocolEncoder and Decoder transforms all messages for a protocol.
* MessageEncoder and Decoder transforms an individual message.

If you are implementing a complex protocol, I'd prefer
MessageEncoder/Decoder/DemuxingProtocolCodecFactory.  SumUp server is a good
example which uses DemuxingProtocolCodecFactory.

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

Re: ProtocolEncoder/Decoder v.s. MessageEncoder/Decoder

Posted by jian wu <he...@gmail.com>.
Hi Mike,

Thanks a lot for your suggestion!

I'll definitely try the TextLineDecoder/TexlineEncoder. And, since there are
other pre-implemented ProtocolDecoder/ProtocolEncoder like
ObjectSerializationDecoder/ObjectSerializationEncoder, I assume that
ProtocolEncoder/ProtocolDecoder will be the first thing to try.

Thanks again,

Jian


On 10/29/06, Mike Grundvig <mi...@electrotank.com> wrote:
> I don't know of any recommendations specifically, but I do know that you can
> probably use the TextLine encoder/decoder to implement the first layer of
> your protocol. This has seemed to work with any delimiter-based protocol
> I've tried.
>
> Michael Grundvig
> Electrotank, Inc
> http://www.electrotank.com
>
>
> ----- Original Message -----
> From: "jian wu" <he...@gmail.com>
> To: <mi...@directory.apache.org>
> Sent: Saturday, October 28, 2006 12:16 PM
> Subject: ProtocolEncoder/Decoder v.s. MessageEncoder/Decoder
>
>
> > Hi,
> >
> > Mina provides two types of classes for encoding/decoding protocol data:
> > ProtocolEncoder/ProtocolDecoder, and MessageEncoder/MessageDecoder.
> >
> > Is there any guideline or recommendation when to use them?
> >
> > In my perticular use case, I'm looking into decoding and encoding a
> > protocol data with fixed start delimiter and end delimiter but length
> > could be varied due to internal data structure.
> >
> > Any suggestion would be really appreciated.
> >
> > Thanks,
> >
> > Jian
> >
>
>
>

Re: ProtocolEncoder/Decoder v.s. MessageEncoder/Decoder

Posted by Mike Grundvig <mi...@electrotank.com>.
I don't know of any recommendations specifically, but I do know that you can 
probably use the TextLine encoder/decoder to implement the first layer of 
your protocol. This has seemed to work with any delimiter-based protocol 
I've tried.

Michael Grundvig
Electrotank, Inc
http://www.electrotank.com


----- Original Message ----- 
From: "jian wu" <he...@gmail.com>
To: <mi...@directory.apache.org>
Sent: Saturday, October 28, 2006 12:16 PM
Subject: ProtocolEncoder/Decoder v.s. MessageEncoder/Decoder


> Hi,
>
> Mina provides two types of classes for encoding/decoding protocol data:
> ProtocolEncoder/ProtocolDecoder, and MessageEncoder/MessageDecoder.
>
> Is there any guideline or recommendation when to use them?
>
> In my perticular use case, I'm looking into decoding and encoding a
> protocol data with fixed start delimiter and end delimiter but length
> could be varied due to internal data structure.
>
> Any suggestion would be really appreciated.
>
> Thanks,
>
> Jian
>