ActiveMQ Topic to Queue,当使用 Camel 路由消息从 Master 切换到 Slave 时丢失?
ActiveMQ Topic to Queue, When using Camel route messages getting lost when switching from Master to Slave?
设置:默认ActiveMQ.XML。本地数据中心的 3 台服务器上每台服务器一个 ActiveMQ 实例,远程数据中心服务器上的一个 ActiveMQ 实例。所有 3 + 1 个实例都是 运行,但在每个数据中心的任何给定时刻,只有一个 ActiveMQ 实例是主实例。来自所有数据中心的所有实例的消息都持久保存到网络 KahaDB,并且我们为每条消息配置了两次重试。
目标:保持数据中心之间的队列同步。
问题: 测试远程服务器何时关闭,所有消息都将 saved/persisted 直到远程服务器重新联机。我将向一个 ActiveMQ 主题发送三个消息。
骆驼路线配置为从主题读取并推送到 2 个本地队列。
第二个骆驼路线被设置为从一个本地队列读取,并将消息推送到远程 ActiveMQ。
当远程服务器关闭(数据中心 2 关闭)时,我们从 Master ActiveMQ(通过停止服务)故障转移到从属服务器,3 条消息中的 1 条是输给了以太。 这似乎是发送到远程服务器的第一条消息。好像连接被拒绝之类的,它永远消失了,甚至没有进入 DLQ?
骆驼配置:
<bean id="local" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:12345"/>
<property name="preserveMessageQos" value="true" />
</bean>
<bean id="remote" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="failover:(tcp://remotehost:54321)"/>
<property name="preserveMessageQos" value="true" />
</bean>
<camelContext id="topicToQueueCamelContext" xmlns="http://camel.apache.org/schema/spring">
<route id="topicToQueue">
<from uri="local:topic:SomeTopic"/>
<to uri="local:queue:SomeQueue"/>
<to uri="local:queue:SomeQueue.Remote"/>
</route>
</camelContext>
<camelContext id="queueToRemoteQueueCamelContext" xmlns="http://camel.apache.org/schema/spring">
<route id="queueToRemoteQueue">
<from uri="local:queue:SomeQueue.Remote"/>
<to uri="remote:queue:SomeQueue"/>
</route>
</camelContext>
已尝试: 将远程 camel 路由设置为事务处理,并在 brokerURL 故障转移传输上设置 trackMessages=true。
有没有人知道哪个 ActiveMQ BrokerURL、ActiveMQ XML 或 Camel URI 查询字符串参数可能丢失了——或者关于如何解决或调试这个丢失消息问题的任何想法?
您需要将 ActiveMQComponent
配置为 consume messages transactional。默认情况下,消息消费是 非 事务性的。这样您可以获得最佳性能,但您也会 "accept" 丢失消息。
设置:默认ActiveMQ.XML。本地数据中心的 3 台服务器上每台服务器一个 ActiveMQ 实例,远程数据中心服务器上的一个 ActiveMQ 实例。所有 3 + 1 个实例都是 运行,但在每个数据中心的任何给定时刻,只有一个 ActiveMQ 实例是主实例。来自所有数据中心的所有实例的消息都持久保存到网络 KahaDB,并且我们为每条消息配置了两次重试。
目标:保持数据中心之间的队列同步。
问题: 测试远程服务器何时关闭,所有消息都将 saved/persisted 直到远程服务器重新联机。我将向一个 ActiveMQ 主题发送三个消息。
骆驼路线配置为从主题读取并推送到 2 个本地队列。
第二个骆驼路线被设置为从一个本地队列读取,并将消息推送到远程 ActiveMQ。
当远程服务器关闭(数据中心 2 关闭)时,我们从 Master ActiveMQ(通过停止服务)故障转移到从属服务器,3 条消息中的 1 条是输给了以太。 这似乎是发送到远程服务器的第一条消息。好像连接被拒绝之类的,它永远消失了,甚至没有进入 DLQ?
骆驼配置:
<bean id="local" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:12345"/>
<property name="preserveMessageQos" value="true" />
</bean>
<bean id="remote" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="failover:(tcp://remotehost:54321)"/>
<property name="preserveMessageQos" value="true" />
</bean>
<camelContext id="topicToQueueCamelContext" xmlns="http://camel.apache.org/schema/spring">
<route id="topicToQueue">
<from uri="local:topic:SomeTopic"/>
<to uri="local:queue:SomeQueue"/>
<to uri="local:queue:SomeQueue.Remote"/>
</route>
</camelContext>
<camelContext id="queueToRemoteQueueCamelContext" xmlns="http://camel.apache.org/schema/spring">
<route id="queueToRemoteQueue">
<from uri="local:queue:SomeQueue.Remote"/>
<to uri="remote:queue:SomeQueue"/>
</route>
</camelContext>
已尝试: 将远程 camel 路由设置为事务处理,并在 brokerURL 故障转移传输上设置 trackMessages=true。
有没有人知道哪个 ActiveMQ BrokerURL、ActiveMQ XML 或 Camel URI 查询字符串参数可能丢失了——或者关于如何解决或调试这个丢失消息问题的任何想法?
您需要将 ActiveMQComponent
配置为 consume messages transactional。默认情况下,消息消费是 非 事务性的。这样您可以获得最佳性能,但您也会 "accept" 丢失消息。