Hi Jeff,

It's great to see you in the mailing list. :)

On 11/7/07, Jeff Mesnil <[EMAIL PROTECTED]> wrote:
> One of our requirements is to support both TCP/IP & HTTP (and their SSL
> flavours).
> The clients and servers must run on only one protocol at the time but it
> must be configurable by the user.
>
> I'm wondering what is the best way to achieve that.
>
> In my prototype, depending on a sys prop, the clients and server may
> have 2 different filter chains
>
> * in the TCP/IP case, both clients and server use a protocol codec
> filter to encode/decode our high level JMS messages directly into MINA
> IoBuffer
> * in the HTTP case, the client and server use an IoFilter to transform
> high level messages into HTTP requests/responses and a HTTP protocol
> codec filter.
>
> This means that we use only high level messages but we must provide for
> each type of message both a codec (for TCP/IP) and a filter (for HTTP).
>
> Does that sound sensible?

Yes.  It's probably because of being firewall-friendly, right?  Here's
my suggestion:

1) Please implement a protocol codec for the TCP/IP case.
2) Use a HTTP codec that accepts IoBuffer (or ByteBuffer) as a message
content. (i.e. HTTP body)
3) There's a class called 'ProtocolCodecSession' which enables you to
use existing codec (the TCP/IP codec in this case) without inserting
it wrapped with ProtocolCodecFilter.  Instead, you will be able to
make the two codecs work together by creating a simple filter that
calls the TCP/IP codec for the HTTP message.

The following is the illustration of my explanation above:

IoService --> ProtocolCodecFilter(HTTP codec inside) -->
YourHTTPContentTransformingFilter(TCP/IP codec inside with help of
ProtocolCodecSession) --> IoHandler

ProtocolCodecSession might take some time in instantiation so you
might want to store it as a thread local variable.

> I've also a concern with my handling of HTTP which is quite ugly.
> I've not found in either asyncweb (from the sandbox) or mina-codec-http
> a codec which supports the encoding/decoding of both HTTP request and
> response.
>
> This means that on the client, I use the codec provided by
> mina-codec-http to encode request / decode response while on the server
> I use the codec provided by asyncweb to decode request / encode response.
> And my HTTP filter is an headache: it transforms JMS messages into
> mina-codec-http's HttpRequestMessage when sending it.
> But it receives a asyncweb's DefaultHttpRequest on the server...
> It works but I find it quite weird to juggle between the 2 implementations.
>
> Stupid question: Have I missed the obvious? :) Is there a "full" http
> codec that I can use on both HTTP client & server?
> If no, is it planned for MINA 2.0 to provide such codec?

There's no full HTTP codec yet unfortunately.  However, it's planned
as you expected.  I'm just running out of my time. ;)

> Keep up the good work, MINA code is very cool to use,

Thanks!  Please don't forget to express some criticism, either. :)

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to