多种语言的 ActiveMQ 发布者和订阅者(​​C++ Java)

发布于 2024-08-18 10:31:30 字数 248 浏览 3 评论 0原文

我想使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

给我一枪 2024-08-25 10:31:30

OpenWire 是一种协议,因此理论上可以在任何地方实现,但这并不意味着每种语言都存在完整的实现。 C++ 客户端的细则显示:

“从版本 2.0 开始,ActiveMQ-CPP 支持 OpenWire v2 协议,但有一些例外。
ObjectMessage - 我们无法在 C++ 中重建 ObjectMessage 中包含的对象,因此,如果您的应用程序订阅了发送给它的 ObjectMessage 的队列或主题,您将收到该消息,但无法提取对象”

如果您想跨进程发送数据,您可以编写 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:

"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

み零 2024-08-25 10:31:30

直接来自 ActiveMQ 的首页:


支持 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

我们已经使用 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

* 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文