ApriOri
ApriOri

Reputation: 2688

Netty based server in servlet container

I have a network server that was implemented using Jboss Netty. It servers the application over both raw TCP and HTTP and running as a stand alone process. Clients connected with TCP can transfer data to clients connected with HTTP and vice versa.

Now I'm required to make it work in servlet environment. Does netty provide a standard way for doing so or that I have to write my adapter? What can I do with the TCP transport? can I include it in the servlet container ?

this is a similar question but without a clear answer

Upvotes: 3

Views: 3849

Answers (1)

AngerClown
AngerClown

Reputation: 6229

You can create an HttpTunnelingServlet that links to your existing Netty implementation. See the org.jboss.netty.channel.socket.http API docs.

This document uses a Spring bean to do the Netty setup. But, it should be easy enough to move your configuration and setup to a ServletListener. I am not 100% sure if this will work though since the setup needs to connect to a LocalAddress that's specified in the servlet config. The issue may be that the address is not valid until the servlet starts up, which happens, I think, after listeners start. Another option would be to sublcass HttpTunnelingServlet and add to the init() implementation.

Whatever method you use, you will still have to setup and also start the TCP channels, etc too like you were doing before.

Upvotes: 2

Related Questions