Buffering ChannelBuffers

David Hoyt dhoyt at llnl.gov
Fri May 22 14:21:26 EDT 2009


Hello,

So here's my problem - I need to buffer all my incoming data in memory until
the connection is closed and then create a java.io.InputStream that
represents all that data that I can then pass on. How do you suggest doing
that?

I looked at using a CompositeChannelBuffer, but I can't continually add
ChannelBuffers as they come in. With CompositeChannelBuffer (and
ChannelBuffers.wrappedBuffer(.)), you have to have all the ChannelBuffers up
front (there is no "addChannelBuffer() method on CompositeChannelBuffer).
Once I have all the data, I see that I can create a
ChannelBufferInputStream.

 

So my code should proceed as follows:

1. Connection is made with server

2. File is downloaded asynchronously

    a. As the file is downloaded in chunks, put each chunk (ChannelBuffer)
into a CompositeChannelBuffer or some other container

3. When file is done or the connection closes, create an InputStream from
the buffered data

4. Process the InputStream normally

 

My main problem is figuring out 2a. I could use some help since I'm still
learning the netty API.

Thanks!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20090522/a8acaec7/attachment.html 


More information about the netty-users mailing list