Netty "cookbook"

"Trustin Lee (이희승)" trustin at gmail.com
Tue Jan 26 06:24:38 EST 2010


Hello David,

If I understood correctly, what you need is
OrderedMemoryAwareThreadPoolExecutor and ExecutionHandler.  They enable
the execution of Netty events in a thread pool.

If you were asking about how to implement the application you described,
I think the proxy server example is a good starting point.  You could
add an HTTP codec into the proxy server.  Of course, there might be a
lot more gory details to deal with - please feel free to ask more
questions to the forum.  Also, you might be interested in Adam Fisk's
HTTP proxy server implementation based on Netty:


http://dev.littleshoot.org:8084/display/proxy/LittleShoot+Java+HTTP+Proxy+-+LittleProxy

HTH,
Trustin

DavidDabbs wrote:
> Hello. I'm new to netty and so am just getting my head into how the gears fit
> together.
> Beyond the example applications, which have been very helpful, is there a
> community 'cookbook?' Please do forward link(s). 
> 
> FWIW, I'm looking into implementing my own "protocol translating" proxy.
> I have ~75msec to do the following:
>   1. accept http POST (protobuf entity)
>   2. parse protobuf, extract string field, lookup (real) user-id
>      2a. Fifty percent of the time, the lookup will be local in an "L1"
> cache; other 50% I need to go over a socket to make the lookup.
>   3. Assemble new protobuf consumed by our backend
>   4. Grab a connection from the appropriate pool.
>   5. Submit request.
>   6. Wait for response.
>   7. Log response.
>   8. Marshal internal response protobuf to external response protobuf.
>   9. Lather, rinse, repeat. (requests will be over looong-running
> Keep-Alives)
> 
> I know I can construct such a pipeline. What I'm not sure of is whether it
> is possible to construct one that pulls the requests off the inbound socket
> and processes them in _parallel_. They would of course need to be written to
> the client FIFO. Because of the various lookups, etc. it is conceivable
> that, for instance, Req#2 could complete before Req#1 if Req#1 has to go
> over the netwoek for the initial lookup and/or if its processing server is
> overloaded (or numerous other things that can happen).
> 
> I just started digging in last night, so forgive me if there's a howto I've
> missed.
> 
> Cheers,
> 
> DavidD
>  

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100126/2a229314/attachment.bin 


More information about the netty-users mailing list