在此ActivEMQ示例中,消息经纪是什么?

发布于 2025-01-28 05:01:54 字数 769 浏览 4 评论 0原文

我是ActiveMQ的新手,并测试了此实现用于请求/响应。

我在同一台计算机上运行Apache ActiveMQ。

它按预期工作,但是我想知道,在服务器代码中使用了什么消息代理:

    try {
        //This message broker is embedded
        BrokerService broker = new BrokerService();
        broker.setPersistent(false);
        broker.setUseJmx(false);
        broker.addConnector(messageBrokerUrl);
        broker.start();
    } catch (Exception e) {
        //Handle the exception appropriately
    }

当我完全删除此块时,它是什么作用,所以它是用的?我认为,在我之前启动的ActiveMQ中实现了一个消息代理,并且用于从队列中读取。为什么我在这里需要一个“嵌入式”经纪人?

I'm new to ActiveMQ and tested this implementation for request/response.

I run Apache ActiveMQ on the same machine.

It works as expected, however I wonder, what the Messagebroker is used for in the server code:

    try {
        //This message broker is embedded
        BrokerService broker = new BrokerService();
        broker.setPersistent(false);
        broker.setUseJmx(false);
        broker.addConnector(messageBrokerUrl);
        broker.start();
    } catch (Exception e) {
        //Handle the exception appropriately
    }

When I remove this block completely, it works anyway, so what is it for? I thought, that a message broker is implemented in the ActiveMQ which I started before and which is used to read from the queue. Why do I need an "embedded" broker here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

懵少女 2025-02-04 05:01:54

这有助于了解ActiveMQ本质上是“只是库”。您可以将其作为独立的服务器(当您在计算机上时)运行,也可以将其嵌入Java代码,单位测试或Java应用程序中。该网页上的示例使用嵌入式ActiveMQ代理(服务器端)提供消息流的多合一视图。

由于您在同一台计算机上运行独立的ActiveMQ经纪人,因此嵌入式经纪人很可能不会被使用 - 因为只有一个过程可以在每台机器一次性上收听61616。

It helps to understand that ActiveMQ is essentially "just a library". You can run it as a stand alone server (as you are on your machine), or embed it within Java code, unit test, or a Java app. The example on that webpage uses an embedded ActiveMQ broker (server-side) to provide an all-in-one view of the message flow.

Since you are running a stand alone ActiveMQ broker on the same machine, that embedded broker is most likely not being used-- since only one process can listen on port 61616 at a time per machine.

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