在此ActivEMQ示例中,消息经纪是什么?
我是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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这有助于了解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.