Hello Andrei,

I think the CumulativeProtocolDecoder is the way to go.
You don't necessarily have to "throw away all the work", since your
decoder could be stateful. When it has partially decoded a record, it
can store this data
and when more data becomes available, continue from there.

How does your existing code determine that you have enough data
to decode a record ?

Maarten

On 9/26/07, Andrei Palskoi <[EMAIL PROTECTED]> wrote:
>
> Hi, I am new to this forum. I have some code that converts COBOL copybook
> records, which can have variable length, into Java objects. For some reasons
> the byte length of the record cannot be passed up front. So my existing code
> uses blocking I/O (buffered InputStream) and it works pretty well.
> I have a server around it that was built on top of Apache Phoenix code. The
> Phoenix project is no longer supported so I've decided to move to Apache
> MINA which looks pretty cool too. However, I am not sure what is the best
> way of integrating my code into it.
>
> As far as I can see, there are two ways:
>
> 1) Implement a subclass of StreamIoHandler and get back to good old blocking
> I/O. But I can see that experts here recommend not doing so unless
> absolutely necessary. Also, why Handler and not Filter?
> 2) Implement a subclass of CumulativeProtocolDecoder that will try to decode
> message and if there is not enough bytes available yet, return false so that
> MINA comes back with more data. Well, that seems highly ineffective,
> especially when working with large records - you have to throw away all the
> work and redo it again when more data becomes available.
>
> Suggestions?
> Thanks, Andrei
> --
> View this message in context: 
> http://www.nabble.com/What-is-a-best-way-of-decoding-variable-size-records--tf4518931s16868.html#a12890468
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>

Reply via email to