面对 ActiveMQ Artemis 的集群测试问题

Facing cluster testing issue with ActiveMQ Artemis

我有 2 个 ActiveMQ Artemis 实例,只是用命令创建的 /.artemis 创建 artemis/server1

/.artemis 创建artemis/server2

我正在使用 linux ubantu。

这是服务器 1 的 broker.xml:

  <acceptors>
     <!-- Acceptor for every supported protocol -->
     <acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>

  </acceptors>

  <connectors>
     <connector name="netty-connector">tcp://localhost:61616</connector>
     <!-- connector to the server1 -->
     <connector name="server1-connector">tcp://localhost:61617</connector>
  </connectors>

 <cluster-connections>
     <cluster-connection name="my-cluster">
        <connector-ref>netty-connector</connector-ref>
        <retry-interval>500</retry-interval>
        <use-duplicate-detection>true</use-duplicate-detection>
        <message-load-balancing>STRICT</message-load-balancing>
        <max-hops>1</max-hops>
        <static-connectors>
           <connector-ref>server1-connector</connector-ref>
        </static-connectors>
     </cluster-connection>
  </cluster-connections>

这是服务器 2 的 broker.xml:

     <!-- Acceptor for every supported protocol -->
   <acceptor name="artemis">tcp://0.0.0.0:61617?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
  </acceptors>

  <connectors>
     <connector name="netty-connector">tcp://localhost:61617</connector>
     <!-- connector to the server0 -->
     <connector name="server0-connector">tcp://localhost:61616</connector>
  </connectors>

  <cluster-connections>
     <cluster-connection name="my-cluster">
        <connector-ref>netty-connector</connector-ref>
        <retry-interval>500</retry-interval>
        <use-duplicate-detection>true</use-duplicate-detection>
        <message-load-balancing>STRICT</message-load-balancing>
        <max-hops>1</max-hops>
        <static-connectors>
           <connector-ref>server0-connector</connector-ref>
        </static-connectors>
     </cluster-connection>
  </cluster-connections>

同样在服务器 2 中,更改 bootstrap.xml,更改 Web 绑定端口

<web bind="http://localhost:8163" path="web">

我正在使用 StaticClusteredQueueExample 和这个示例工作文件对其进行测试。

现在我 运行 ActiveMQ Artemis JMeter Performance 针对我的集群,我正在使用 JMeter 测试示例,它是 here

现在,当我 运行 point to point test 使用 Jmeter 时,消费者的错误率(Jmeter 中的汇总报告)接近 50%,

但是我 运行 在 ubantu 系统中只有一个节点(server1 或 server2 中的任何一个),它工作正常,错误率为 0%(Jmeter 中的汇总报告)。

当 运行 多个实例(节点)与 docker

时,为什么我得到 50% 的错误率(Jmeter 中的汇总报告),你能帮忙吗?

问题是您将一个示例(即 JMeter 示例)与集群配置(即来自 clustered-static-discovery 示例)混合在一起,这实际上是不兼容的。

<message-load-balancing> of the cluster is STRICT which means messages will be load-balanced across the cluster regardless of the presence of consumers. Furthermore, the default <redistribution-delay> 为 -1,这意味着由于 STRICT 消息负载平衡类型而发送到集群中其他节点的消息将保留在这些节点上,并且不会根据消费者需求重新分配。

JMeter 示例是在考虑单个节点的情况下编写的,因此它只向 1 个节点发送消息并使用来自 1 个节点的消息,这意味着它只会收到它发送的一半消息,因为另一半将被转发由于配置,到集群中的另一个节点。

如果您将 更改为 ON_DEMAND 您将不会看到任何错误,因为所有消息都将保留在专门发送它们的节点上,这也是消费者将要发送的节点已连接。