首页 > 解决方案 > 复制的 ActiveMQ Artemis 服务器 - 不复制消息

问题描述

我已经配置了 ActiveMQ 主服务器和从服务器。

如果主服务器发生故障,从服务器被设置为活动服务器,但来自主服务器的先前消息不可用。

主配置(broker.xml):

      <connectors>
        <!-- Connector used to be announced through cluster connections and notifications -->
        <connector name="artemis">tcp://192.168.2.200:61616</connector>
        <!-- connector to the slaves -->
        <connector name="slave1-connector">tcp://192.168.2.112:61616</connector>
      </connectors>

      <ha-policy>
         <replication>
            <master>
               <!--we need this for auto failback-->
               <check-for-live-server>true</check-for-live-server>
            </master>
         </replication>
      </ha-policy>
      
      <cluster-user>admin</cluster-user>
      
      <cluster-password>admin</cluster-password>
      
      <cluster-connections>
         <cluster-connection name="my-cluster">
            <connector-ref>artemis</connector-ref>
            <message-load-balancing>STRICT</message-load-balancing>
            <static-connectors>
               <connector-ref>slave1-connector</connector-ref>
            </static-connectors>
         </cluster-connection>
      </cluster-connections>

从站配置(broker.xml):

    <connectors>
        <!-- Connector used to be announced through cluster connections and notifications -->
        <connector name="artemis">tcp://192.168.2.112:61616</connector>
        <!-- connector to the master -->
        <connector name="master-connector">tcp://192.168.2.200:61616</connector>
    </connectors>

      <ha-policy>
         <replication>
            <slave>
               <allow-failback>true</allow-failback>
               <!-- not needed but tells the backup not to restart after failback as there will be > 0 backups saved -->
               <max-saved-replicated-journals-size>0</max-saved-replicated-journals-size>
               <failback-delay>2000</failback-delay>
            </slave>
         </replication>
      </ha-policy>

      <cluster-user>admin</cluster-user>
      <cluster-password>admin</cluster-password>
      <cluster-connections>
         <cluster-connection name="my-cluster">
            <connector-ref>artemis</connector-ref>
            <message-load-balancing>STRICT</message-load-balancing>
            <static-connectors>
               <connector-ref>master-connector</connector-ref>
            </static-connectors>
         </cluster-connection>
      </cluster-connections>

这些配置有什么问题?

标签: activemq-artemis

解决方案


为了复制消息,它们必须是持久的(即持久的)。根据定义,非持久消息是易变的,因此不会被复制。


推荐阅读