ArtemisMQ 连接器

ArtemisMQ Connector

我是ArtemisMQ的新手,完全不懂connectors的意思。

为什么connector是必不可少的,因为我们已经在broker.xml中指定了Broker Server的accepter -> 我们知道要发送哪个端口(它是accepter端口)如果我们想连接到这个服务器的请求。即使此服务器是集群的一部分,connector 的作用是什么?也有信息 from other part of documentation about "Clusters",但是有关于 cluster connections 的话:

The cluster is formed by each node declaring cluster connections to other nodes in the core configuration file broker.xml. When a node forms a cluster connection to another node, internally it creates a core bridge (as described in Core Bridges) connection between it and the other node, this is done transparently behind the scenes - you don't have to declare an explicit bridge for each node. These cluster connections allow messages to flow between the nodes of the cluster to balance load.

来自 documentation "Understanding Connectors"

connectors are used by a client to define how it connects to a server.

"define how"是什么意思?

我已经阅读 ,但对我没有帮助。

其他问题:

注意两点:

  • connector不是必需的,具体取决于您的用例。您会发现默认的 broker.xml 没有定义任何 connector 元素。例如,如果您只是 运行 ./artemis create,生成的 broker.xml 没有任何 connector 元素。
  • 您引用的文档很旧(来自 Artemis 的第一个版本)。您可能会从阅读 latest documentation 中获益,为了清晰起见,在许多地方进行了更新。

如文档和您引用的其他 Stack Overflow 答案中所述,代理中的某些组件需要连接到 其他 代理(例如核心网桥、集群连接、 ETC。)。 connector 封装了这些其他组件建立所需连接所需的信息。就这么简单。

现在关于您的个人问题...

Even if this server is part of cluster, what is a role of connector?

在集群使用 broadcast-groupdiscovery-group 的情况下,集群中的每个节点都需要广播到集群中的所有 other 节点群集其他节点如何连接到自身。它通过广播在 cluster-connection 配置中引用的 connector 来实现。当集群中的其他节点收到此广播时,它们会获取 connector 信息并使用它连接回最初广播它的节点。通过这种方式,节点可以动态地发现并相互连接。还值得注意的是,在这种情况下,connector 配置实质上将反映代理的 acceptor 配置之一(因为 connector 将被其他节点用于连接到广播节点的 acceptor). cluster documentation.

中对此进行了进一步讨论

...connectors are used by a client to define how it connects to a server...

您引用的这段文档是准确的,但可能有点混乱。请记住, 客户端 可以 运行 任何地方,甚至在代理本身内。在核心网桥和集群连接的情况下,代理中有一个客户端 运行ning,它使用 connector 来确定如何连接到另一个代理。对于它的价值,更新后的文档没有这个特定的措辞。

What does it mean "define how"?

一个connector是client需要连接到broker的URL。 URL 可以简单地包含主机和端口,也可以包含连接的大量配置详细信息(例如 SSL 配置)。

Is connector always the same as acceptor..?

不,不是总是。在集群的情况下,由于我已经概述的原因,它们将相同(或非常接近),但在网桥的情况下,它们将不相同。

What information does connector encapsulates..?

见上文。

Why does stand-alone Broker have connector, for example by default creation ./artemis create?

没有。见上文。

What should we write in connector?

URL 需要连接。

Can you give a simple example when acceptor and connector are different?

如前所述,桥接是使用不同受体和连接器的示例。 ActiveMQ Artemis 在 examples/features/standard 目录中附带了一个 "core-bridge" 示例,该示例演示了不同的接受器和连接器。该示例涉及 2 个不同的代理,其中一个代理具有配置为向另一个代理发送消息的核心桥。 Here's the broker.xml with the bridge defined. You can see the acceptor listening on the localhost:61616 and the connector for localhost:61617. This connector points to the other broker which is listening on localhost:61617.