views:

108

answers:

1

Hello everyone,

I have coded a server that uses Protocol Buffers in Java. A client talks to it using PB. I'd like to migrate the server code to J2EE and take advantage of the containers' built-in features like clustering.

How can I have a service that receives PB messages and interprets them properly, and then gets them handled?

I was thinking of a dedicated type of servlet, but how can it be done?

I'm a J2EE newbie... I'm not familiar enough with J2EE application servers to know if there is a way to make that happen.

P.S. I'm looking for a solution that uses TLS sockets directly. No overhead-causing middleman protocols like HTTP are welcome here.

P.P.S. Open source solutions only please.

A: 

If you look at the servlet classes, they suggest that it should be possible to build any kind of servlet that supports any kind of protocol, not just HTTP (you'd think that it should be possible to create your own kind of servlet that extends GenericServlet, just like HttpServlet does).

However, in practice this is not possible, because the Java EE server that you'll be running it on most likely only supports standard HTTP servlets. There's no standard way to make Java EE servers support servlets for other kinds of protocols. So trying to write your own protocol-specific servlet is not the way to go.

Jesper
great :(So, what would be the way to go?
mlaverd
I'm looking at the JBoss bindings file, and it looks like they have many services like RMI that wouldn't use HTTP. Can't that be leveraged?
mlaverd
But that uses RMI which is just another protocol, just like HTTP... What you seem to be looking for is a way to listen on a socket and when a client opens a connection, handle all the data communication yourself. You don't want another protocol like RMI sitting in between. Maybe JBoss has a way to plug in a socket listener (search the JBoss docs), but it's certainly not standard Java EE functionality.
Jesper