ActiveMQ不会在故障转移重新连接

时间:2018-03-28 15:56:21

标签: activemq

我正在尝试使用通过双工WAN连接器桥接两个LAN的代理网络:

logical layout of brokers

  • 我们的设置中实际上有很多订阅者,如果这是有意义的,每个订阅者都连接到不同的“Broker A”。所有Broker A实例都有自己与单个“Broker B”的连接。

软件和配置:

  • ActiveMQ 5.14.0,Java 8
  • 所有经纪人只有非持久性主题;咨询信息已经开启。
  • 操作系统:Linux(RHEL 6)

当我最初将所有内容都放到网上时,无论我在线播放的顺序如何,发布者和订阅者之间的沟通都能完美无瑕。我已经让系统连续几周运行并且没有问题。

我观察到的是,如果重新启动代理C,则代理B中不会出现新的主题。代理B中出现新主题,因为它们是由订阅者创建的。现有的或新的主题都没有通过WAN传播到代理C.我已经使用jconsole验证了这一点。

如果我重新启动经纪人B,问题会立即消失。经纪人B中包含的主题(根据jconsole)与重启之前的主题相同,但现在他们神奇地出现在C中。

经纪人B和C具有相同的配置(如下所示)。唯一的区别是B创建了使用以下代码创建的C的双工网络连接器:

final NetworkConnector wanNC = new DiscoveryNetworkConnector(
        new URI(String.format("static:(failover:(tcp://%s:%d))", parentNode, port)));
wanNC.setCheckDuplicateMessagesOnDuplex(true);
wanNC.setDecreaseNetworkConsumerPriority(true);
wanNC.setDuplex(true);
wanNC.setName(NetworkUtils.getHostName());
wanNC.setNetworkTTL(10);
wanNC.setSuppressDuplicateTopicSubscriptions(false);

broker.addNetworkConnector(wanNC);

broker.xml:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <!-- Allows us to use system properties as variables in this configuration file -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />

    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="${broker.id}" start="false"
        offlineDurableSubscriberTimeout="5000" offlineDurableSubscriberTaskSchedule="5000"
        persistent="false" useJmx="true" schedulePeriodForDestinationPurge="86400000">

        [...]

        <networkConnectors>
            <networkConnector name="z-broker-${broker.id}-x-nc"
                decreaseNetworkConsumerPriority="true"
                networkTTL="10"
                uri="multicast://225.5.5.5:6555?group=TO_X">
                <excludedDestinations>
                    <topic physicalName="X.A" />
                </excludedDestinations>
            </networkConnector>
            <networkConnector name="z-broker-${broker.id}-y-nc"
                decreaseNetworkConsumerPriority="true"
                networkTTL="10"
                uri="multicast://225.5.5.5:6555?group=TO_Y">
                <excludedDestinations>
                    <topic physicalName="X.B.>" />
                </excludedDestinations>
            </networkConnector>
        </networkConnectors>

        <transportConnectors>
            <transportConnector name="openwire"
                uri="tcp://${broker.ip}:${broker.port}?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"
                discoveryUri="multicast://225.5.5.5:6555?group=TO_Z" />
        </transportConnectors>
    </broker>
</beans>
  1. 为什么经纪人B(现有的或新的)的主题不会出现在经纪人C?
  2. 为什么重启经纪人B会立即解决问题?

1 个答案:

答案 0 :(得分:0)

显然诀窍是改变网络连接器URI

static:(failover:(tcp://<ip>:<port>))

static:(tcp://<ip>:<port>)

由于任何原因我都不需要故障转移传输,因为连接是作为网络桥接而且只有一个远程地址。

无论出于何种原因,使用故障转移都会阻止主题在重新连接时传播。

相关问题