views:

78

answers:

2

By "local" I mean both run in the same subnet, in most cases the same host/VM, therefore some standard cross-network cross-platform RPC mechanisms like SOAP, XML-RPC, CORBA, etc. seem unnecessary.

The payload is mainly numerical (mostly tabulated) data with some small amount of meta data (for example available data services, data description/type, etc.) from C++ to Java, and console/scripted UI events from Java to C++. So the C++ program acts like the server and Java program the client.

I can enumerate several options (mostly from searching this wonderful site) but I've never used or seen one in a real-world heavy-duty situation, so I really hope someone who's "been there, done that" can educate me about the pros and cons of the options.

  1. Shared memory
  2. Pipe, stdin/stdout, etc.
  3. Custom data structure over plain socket (probably UDP) (this question)
  4. Messages over plain socket, could be Google protocol buffer, Thrift, JSON, etc. (this answer, among others)
  5. Java RMI with C++ RMI server (this question)
  6. JNI (some answers in this question)

I'm pretty sure I've missed many options. Thank you all for your help!


Edited: I forgot to mention that performance is not a major concern as the data throughput is not expected to be huge (server is heavily database-bound), but it would be important to know if one option stands out to be much faster or slower. For example, I suppose nothing beats shared memory (if done right).

+3  A: 

Options 3 and 4 are used in real-world heavy-duty situations.

Options 1,2,6 do not reach another host.

Option 5 is probably too troublesome for the non-Java side.

I'd go with Option 4, because Option 3 is too low-level (unless Option 4 turns out to be too slow). Choose your favourite cross-platform light-weight messaging protocol from the ones you enumerated. Those are all "battle-tested" and have libraries for most languages.

Thilo
Thanks! As I said the two programs are very likely to be on the same host, so I'd greatly appreciate if you can elaborate on the same-host options as well. Regarding the messaging protocols, I know each one has pros and cons but do you have a favorite of your own?
std_colon-colon_ex
As for same-host communication, I'd still go with Option 4 to localhost first, and only consider making it more complex if this turns out to be too slow.
Thilo
+1  A: 

I'd go with option 4. I'd skip 5. 2 would be clunky.

We're talking passing the numerics as plain text, yes?

Tony Ennis
No, why? I certainly want to take advantage of protobuf's varint, for example.
std_colon-colon_ex
Passing plain text is much easier to debug and process as it removes any weird binary format issues. Text is a lot larger than binary of course, but you say your transaction rate is going to be relatively low. I'd pass text of I could and only fall back to binary if I had to.
Tony Ennis
weird binary format issues should not be a problem when using an established wire format like protobuf.
Thilo