Serving images over http using Netty
"이희승 (Trustin Lee)"
trustin at gmail.com
Tue Jun 21 01:16:57 EDT 2011
Drew Kutcharian wrote:
> Hi Everyone,
>
> I would like to know what's the best way to serve images that are hosted in a document database using Netty.
>
> I'm new to Netty and I started looking at the the HttpStaticFileServer, but I don't think that would be a good example since, it uses RandomAccessFile and does a lot of "file dependent" things.
>
> I will only be sending small images, so I was thinking I can just read the whole byte[] from the DB and then use Netty to send it to the user.
>
> What is the fastest/optimized way to do this? How should I configure Netty? What should I include in the pipeline? What kind of ServerSocketFactory and ThreadFactory should I use?
Then you can just wrap the byte[] with ChannelBuffer and write it into a
Channel.
> In addition, how should I handle the database connection?
In a separate thread pool. You could use an ExecutionHandler or create
your own thread pool and submit tasks to it so that the tasks that take
long time are run in a different thread than an I/O thread.
HTH
--
Trustin Lee, http://gleamynode.net/
More information about the netty-users
mailing list