views:

428

answers:

2

I want to use ActiveMQ as a message broker communicating between a C++ component and a Java component in two process. Eg. C++ component is the publisher and the Java component is the subscriber(there maybe multiple subscribers). I look at ActiveMQ website and it mentions the tool OpenWire and ActiveMQ-CPP. However, all the examples on the websites are using the same language for both producer and consumer.

My questions are:

1.Can ActiveMQ work for producer/consumer in different languages?

2.In different processes? How?

Totally newbie in this field, and any suggestion is welcomed.

Lily

+1  A: 

OpenWire is a protocol and hence can theoretically be implemented anywhere, but that doesn't mean full implementations exist for every language. The fine print of the C++ client says:

"As of version 2.0, ActiveMQ-CPP supports the OpenWire v2 protocol, with a few exceptions. ObjectMessage - We cannot reconstruct the object(s) contained in an ObjectMessage in C++, so if your application is subscribed to a queue or topic that has an ObjectMessage sent to it, you will receive the message but will not be able to extract an Object from it."

So if you want to send data across processes, you write your C++ and Java components to use the API (making sure not to use ObjectMessage types if you're using ActiveMQ-CPP). Then run the ActiveMQ server... tell your programs to connect to it, and it should work.

But if you're really just trying to do interprocess communication when you control both clients, this could be a bit heavy-handed. You might be interested in the responses to What is the best approach for IPC between Java and C++? and Good alternative to shared memory IPC for Java/C++ apps on Linux

Hostile Fork
why ActiveMQ is heavy-handed?
Lily
My understanding is that you have to run an ActiveMQ process, so you've now got a total of three processes running (along with all the worry that comes with running and configuring the brokering server). If you use shared memory then your processes can talk directly, and if you use sockets you get the ability to run your programs on different machines if you wish. Each level of abstraction gives you something, and you may-or-may-not need that something for your application.
Hostile Fork
thanks for your reply. I do want to run different modules on different machines. Actually, in my case, it's a publisher/subscriber pattern (multiple publisher/multiple subscriber) I am not sure which one is better: socket vs. ActiveMQ?
Lily
I've not used ActiveMQ...but that wasn't necessary to answer your original question. With "what's better" issues I'm out of my depth. :) But if you control the C++ and the Java code then there doesn't seem to be a strong reason why they wouldn't just speak the same format over something like Google Protocol Buffers and you wouldn't need a "message broker". But maybe ActiveMQ is great for publish/subscriber features regardless. Perhaps ask a new question "Which is better for publish/subscribe network services, ActiveMQ or Bonjour or..." and someone who knows more than I do can answer it.
Hostile Fork
A: 
Pascal Sartoretti