Using Apache ActiveMQ with C/C++
We are writing new C/C++ code which needs integration into the ActiveMQ message bus. There's a lot of options for this:
- CMS is an easy-to-use JMS-like API for C++.
- OpenWire C Client (only available in ActiveMQ 4.x or later).
- OpenWire C++ Client
- Stomp C client (libstomp)
Then there's "wilder" options like the REST API, linking to the ActiveMQ Java client using JNI, SOAP, XMPP... So, what should I use to integrate my C/C++ application with ActiveMQ, and why?
Of the four clients that you list only ActiveMQ-CPP (CMS) is actively maintained; the rest have not been active in a long time. That being said you should use the option that best fits your project's needs. ActiveMQ-CPP would allow you to use all the same features as a JMS client and supports broker failover as well as giving you access to some ActiveMQ specific features like deleting destinations, message compression, etc.
The requirements of your project should dictate the choice in the end.
Yes, ActiveMQ-CPP CMS is good option to integrate our legacy C code. but I have also done integration of c code with java (JMS) as listener(Replier) using JNI and the called c function from java listener. In our case , we have java listener, which actively listens the message from activemq broker then pass that message to native c function using JNI and responded message from c function again sent back to activemq broker using getJMSReplyTo and getJMSCorrelationID.
we have done both approaches, which listens message from AMQ broker and passes message to c function and send back responded / processed message to AMQ broker.
however I am interested to know on below points
- which will be the best option and why?
- if we go Java & C using JNI then will any performance issue or concurrency issue to call shared c library (.so library) from Java?