Question

I'm planning on writing an RPC server in Java. The server needs to accept incoming RPCs - probably over HTTP - and answer them. Fairly basic stuff. Support for 'long polling' or 'hanging' RPCs isn't necessary, so a thread-per-request model ought to be perfectly adequate.

If I were writing this in Python, I would probably use a framework like twisted. In C, something like glibc. In each case, the framework provides an implementation of the general 'select loop' core of handling IO and invoking higher level constructs that deal with it, eventually leading to my application being called for events such as receiving an RPC.

It's a long time since I wrote anything substantial in Java, though, so I don't know what the state of the art or the suggested solutions are for this sort of thing. Possibly there's even parts of the standard library I can easily use to do this. Hence my question to StackOverflow: What frameworks are there out there that would be suitable for a task like this?

Note that although I may use HTTP for the RPCs, this is emphatically not a web application - and as such, a web framework is not appropriate.

Was it helpful?

Solution

Apache MINA is a very well designed asynchronous non-blocking networking framework. It provides byte-oriented access to read and write packet data. Building atop that it has a filter system where additional layers can be added, providing things like line-oriented text parsing, encryption (via TLS), compression, etc.

PS: The 2.0 release series is highly recommended, even though it's still in "milestone" form, it's proven very stable and is nearing a final release.

OTHER TIPS

You have multiple choice:

  • Roll your own solution with the existing SDK for socket programming.
  • Java RMI, the remote method invocation framework.
  • Java CORBA bindings, is no longer considered current.
  • Java Web Service frameworks, are quite complex. Look at Apache CXF and the different J2EE products.

Then you have different systems running above HTTP transport like JSON/XML-RPC where you need a Web server. Even though you rule them out.

You could consider using some thing as simple as Jetty the internals of jetty are very stable and can handle quite silly number of connections. If you implement the jetty specific handler interface you can also do with out all of the servlet and JSP support libraries making it quite a small embedable app server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top