Apache Artemis - 来自同一组ID的消息由多个消费者接收

时间:2018-01-26 11:22:27

标签: spring-boot jms spring-jms activemq-artemis wildfly-11

我有两个部署的应用程序,一个在我的本地计算机上,一个在服务器上。这两个应用程序都通过安装在服务器上的相同Artemis客户端进行通信。 Artemis版本是1.5.5。

当我执行一个简单的测试,发送1000个分为多个组的消息时会出现问题,在这种情况下,服务器应用程序中有50个组(数字不重要,无论消息或组的数量是多少)。本地应用消费者接收每个组和几乎所有消息。这是因为服务器应用程序消费者只收到一条消息 - 比如说 - 组号5.这种行为在多个组中重复。

为什么会这样?同样,消费者和生产者都在同一个Artemis上工作。应用程序使用Spring boot编写。使用Spring的bootRun任务部署本地应用,而服务器应用部署在Wildfly-11.0.0.Final

这是我的broker.xml文件:

    <configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
  <jms xmlns="urn:activemq:jms">
    <queue name="DLQ"/>
    <queue name="ExpiryQueue"/>
    <queue name="AlarmsQueue"/>
  </jms>
  <core xmlns="urn:activemq:core">
    <name>0.0.0.0</name>
    <persistence-enabled>true</persistence-enabled>
    <!-- this could be ASYNCIO or NIO
       -->
    <journal-type>ASYNCIO</journal-type>
    <paging-directory>./data/paging</paging-directory>
    <bindings-directory>./data/bindings</bindings-directory>
    <journal-directory>./data/journal</journal-directory>
    <large-messages-directory>./data/large-messages</large-messages-directory>
    <journal-datasync>true</journal-datasync>
    <journal-min-files>2</journal-min-files>
    <journal-pool-files>-1</journal-pool-files>
    <!--
       This value was determined through a calculation.
       Your system could perform 8.06 writes per millisecond
       on the current journal configuration.
       That translates as a sync write every 124000 nanoseconds
      -->
    <journal-buffer-timeout>124000</journal-buffer-timeout>
    <!-- how often we are looking for how many bytes are being used on the disk in ms -->
    <disk-scan-period>5000</disk-scan-period>
    <!-- once the disk hits this limit the system will block, or close the connection in certain protocols
           that won't support flow control. -->
    <max-disk-usage>95</max-disk-usage>
    <!-- the system will enter into page mode once you hit this limit.
           This is an estimate in bytes of how much the messages are using in memory -->
    <global-max-size>104857600</global-max-size>
    <acceptors>
      <!-- Default ActiveMQ Artemis Acceptor.  Multi-protocol adapter.  Currently supports ActiveMQ Artemis Core, OpenWire, STOMP, AMQP, MQTT, and HornetQ Core. -->
      <!-- performance tests have shown that openWire performs best with these buffer sizes -->
      <acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</acceptor>
      <!-- AMQP Acceptor.  Listens on default AMQP port for AMQP traffic.-->
      <acceptor name="amqp">tcp://0.0.0.0:5672?protocols=AMQP</acceptor>
      <!-- STOMP Acceptor. -->
      <acceptor name="stomp">tcp://0.0.0.0:61613?protocols=STOMP</acceptor>
      <!-- HornetQ Compatibility Acceptor.  Enables HornetQ Core and STOMP for legacy HornetQ clients. -->
      <acceptor name="hornetq">tcp://0.0.0.0:5445?protocols=HORNETQ,STOMP</acceptor>
      <!-- MQTT Acceptor -->
      <acceptor name="mqtt">tcp://0.0.0.0:1883?protocols=MQTT</acceptor>
    </acceptors>
    <security-settings>
      <security-setting match="#">
        <permission type="createNonDurableQueue" roles="guest"/>
        <permission type="deleteNonDurableQueue" roles="guest"/>
        <permission type="createDurableQueue" roles="guest"/>
        <permission type="deleteDurableQueue" roles="guest"/>
        <permission type="consume" roles="guest"/>
        <permission type="browse" roles="guest"/>
        <permission type="send" roles="guest"/>
        <!-- we need this otherwise ./artemis data imp wouldn't work -->
        <permission type="manage" roles="guest"/>
      </security-setting>
    </security-settings>
    <address-settings>
      <!--default for catch all-->
      <address-setting match="#">
        <dead-letter-address>jms.queue.DLQ</dead-letter-address>
        <expiry-address>jms.queue.ExpiryQueue</expiry-address>
        <redelivery-delay>0</redelivery-delay>
        <!-- with -1 only the global-max-size is in use for limiting -->
        <max-size-bytes>-1</max-size-bytes>
        <message-counter-history-day-limit>10</message-counter-history-day-limit>
        <address-full-policy>PAGE</address-full-policy>
      </address-setting>
    </address-settings>
    <connectors>
      <connector name="netty-connector">tcp://<ip>:61616</connector>
    </connectors>
    <ha-policy/>
    <broadcast-groups>
      <broadcast-group name="my-broadcast-group">
        <group-address>${udp-address:<ip>}</group-address>
        <group-port>9876</group-port>
        <broadcast-period>2000</broadcast-period>
        <connector-ref>netty-connector</connector-ref>
      </broadcast-group>
    </broadcast-groups>
    <discovery-groups>
      <discovery-group name="my-discovery-group">
        <group-address>${udp-address:<ip>}</group-address>
        <group-port>9876</group-port>
        <refresh-timeout>10000</refresh-timeout>
      </discovery-group>
    </discovery-groups>
    <cluster-connections>
      <cluster-connection name="my-cluster">
        <address>jms</address>
        <connector-ref>netty-connector</connector-ref>
        <retry-interval>500</retry-interval>
        <message-load-balancing>STRICT</message-load-balancing>
        <max-hops>1</max-hops>
        <discovery-group-ref discovery-group-name="my-discovery-group"/>
      </cluster-connection>
    </cluster-connections>
  </core>
</configuration>

0 个答案:

没有答案