New to netty
Trustin Lee
tlee at redhat.com
Mon Dec 8 05:17:04 EST 2008
Hello,
On Mon, Dec 08, 2008 at 01:37:40AM +0900, manish_iitg wrote:
>
> Hello,
>
> I am new to netty. This is my first time with any NIO Frameworks. After
> searching on the internet, i found out netty was the best nio framework so
> decide to build my application on netty.
Thanks for choosing Netty first of all, and I'd love to hear your feed
back!
> I am creating a application, in which my netty server need to query a mysql
> database depending upon the request from the client. My client is a swing
> application, and it send an request object to the netty server. I am using
> ObjectEncoder and ObjectDecoder for encoding and decoding the request
> object. On the server side, i have written a simple handler, and in the the
> messageRecieved function i query the database according to the request
> object and reply back. In database querry in is simple select function which
> is called from a static class.
>
> I want to know weather this architecture is good enough, if the number of
> request increase. Also what would be the best architecture for such kind of
> application.
You are pretty close to prefection IMHO. One left thing I can think of
is to add an ExecutionHandler (org.jboss.netty.handler.execution) to the
pipline. By adding an ExecutionHandler which wraps a OrderedMemoryAware-
ThreadPool (org.jboss.netty.handler.execution), you can make your
handler to process the events in a different thread pool than the I/O
thread pool. Because you are performing a time-consuming task which
might block the I/O thread, it is recommended to add an ExecutorHandler
somewhere between the head of the pipeline and your handler that queries
MySQL.
The following is a simple example that adds an ExecutorHandler as
explained above:
bootstrap.getPipeline().addLast("executor", new ExecutionHandler(
new MemoryAwareThreadPoolExecutor(16, 0, 0)));
bootstrap.getPipeline().addLast("handler", handler);
HTH,
--
Trustin Lee, Principal Software Engineer, JBoss, a division of Red Hat
--
what we call human nature in actuality is human habit
--
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20081208/50b443a7/attachment.bin
More information about the netty-users
mailing list