On 20/12/2013 06:13, fulin tang wrote:
> Hi, there:
> 
> We are using Tomcat a lot in our production environment, mainly for http
> rest apis. (A lot here means over a thousand instances), and we have just
> upgraded to 7.0.25 from 6.0.32 last month.
> 
> And meanwhile, we are developing our own RPC framework, based on Hessian,
> MsgPack etc, we designed our own RPC protocol, a very simple but flexible
> protocol, for supporting text and binary transport at the same time, and
> for configurable serialization, because we have to support multi language
> users, and our users already have their own choices.
> 
> So, here is the problem: We want to combine the rest api Tomcat instances
> and the RPC java instances together, in the framework level. Let's say, we
> already have HTTP, HTTPS, AJP, Comet, WebSocket protocols here in Tomcat,
> what if we add our RPC protocol parser besides them, maybe we need another
> rpcRequest and rpcResponse, or we can dispatch all RPC call to a default
> servlet, and let user do their jobs in that servlet.
> 
> I looked at the source code, and as far as I see, Tomcat is not ready for
> this, because it is not designed to do this, there are too many code to
> change. Is there any chance for Tomcat to support user-defined protocol
> later, or I just take the wrong way?

There are two obvious places where you can do this.

The first is to add another protocol under org.apache.coyote (like AJP,
HTTP and SPDY). This approach gives you the greatest control but
requires the most work. As an aside, there is probably still some scope
for refactoring this code to reduce duplication and make it easier to
extend. As always, patches are welcome. (Small incremental patches are
best for this sort of thing.)

The second is to use HTTP Upgrade. This is part of the Servlet 3.1 API
so requires Tomcat 8. However, it has been back-ported to Tomcat 7 and
can be used there to (with some minor modifications). Take a look at how
WebSocket is implemented to get an idea of how you might do this. Start
with org.apache.tomcat.websocket.server.WsFilter. You can start here in
both Tomcat 7 and Tomcat 8 and see how they compare.

The downside of the upgrade approach is that you only have access to the
input and output streams, not the sockets so you end up having to
manually handle things like timeouts (if you want to do things in a
container neutral way).

HTH,

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to