多种语言的 ActiveMQ 发布者和订阅者(C++ Java)
我想使用 ActiveMQ 作为消息代理,在两个进程中的 C++ 组件和 Java 组件之间进行通信。例如。 C++组件是发布者,Java组件是订阅者(可能有多个订阅者)。我查看了 ActiveMQ 网站,它提到了 OpenWire 和 ActiveMQ-CPP 工具。然而,网站上的所有示例对于生产者和消费者都使用相同的语言。
我的问题是:
1.ActiveMQ可以为不同语言的生产者/消费者工作吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
OpenWire 是一种协议,因此理论上可以在任何地方实现,但这并不意味着每种语言都存在完整的实现。 C++ 客户端的细则显示:
如果您想跨进程发送数据,您可以编写 C++ 和 Java 组件来使用 API(如果您使用的是 ActiveMQ-CPP,请确保不要使用 ObjectMessage 类型)。然后运行 ActiveMQ 服务器。告诉你的程序连接到它,它应该可以工作,
但是如果你真的只是在控制两个客户端时尝试进行进程间通信,那么你可能会对 < 的响应感兴趣。 a href="https://stackoverflow.com/questions/165945/what-is-the-best-approach-for-ipc- Between-java-and-c">Java 和 C++ 之间 IPC 的最佳方法是什么? 和 不错的选择到 Linux 上 Java/C++ 应用程序的共享内存 IPC
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:
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
直接来自 ActiveMQ 的首页:
支持 Java、C、C++、C#、Ruby、Perl、Python、PHP 等多种跨语言客户端和协议
我们已经使用 PHP(使用 Stomp)和 Java(使用开放线)。
关于进程:不同的生产者和消费者当然可以处于完全不同的进程中,通过 TCP 或 SSL 等进行通信。
Directly from ActiveMQ's front page :
Supports a variety of Cross Language Clients and Protocols from Java, C, C++, C#, Ruby, Perl, Python, PHP
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.