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 c开发者_开发百科onsumer.
My questions are:
1.Can ActiveMQ work for producer/consumer in different languages?
2.In different processes? How?
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
Directly from ActiveMQ's front page :
Supports a variety of Cross Language Clients and Protocols from Java, C, C++, C#, Ruby, Perl, Python, PHP
* OpenWire for high performance clients in Java, C, C++, C#
* Stomp support so that clients can be written easily in C, Ruby, Perl,
Python, PHP, ActionScript/Flash, Smalltalk to talk to ActiveMQ as well
as any other popular Message Broker
We have tested it with PHP (using Stomp) and Java (using OpenWire).
Regarding processes : the various producers and consumers can of course be in totally different processes, communicating over e.g TCP or SSL.
精彩评论