ActiveMQ网络的经纪人消息不平衡

时间:2016-10-19 08:53:55

标签: jms activemq spring-jms

我正在使用 ActiveMQ 5.13.4 ,我设置了一个network-of-brokers,其中包含两个通过{{1}连接的代理AB }}。每个经纪人都有一个与之相关的消费者(networkConnectorA')。 B'A'使用来自同一B'的消息(例如distributed queue)。每个使用者都是一个java应用程序,由具有requests-queue设置的Spring DefaultJmsListenerContainerFactory表示。基本上,每个消费者有最多10个线程,可以同时消耗来自队列的消息。

在代理配置(concurrency: 5-10)中,我将预取大小设置为1,假设消息不多而且需要大量处理时间。

activemq.xml

期望的行为是当我向 <policyEntry queue=">" producerFlowControl="true" optimizedDispatch="true" queuePrefetch="1" enableAudit="false"> 发送100条消息时,它同时开始处理10条消息(每个消费者线程一条消息)并将另外10条消息转发给A。当B完成处理前10条消息时,它将获得额外的10条消息。这将持续到所有消息都被处理完毕。

实际行为是当我向B发送100条消息时,它会向本地消费者A发送10条消息(每个线程一条消息)并转发剩余的消息90到A'B'上的消费者完成了对消息的处理,他们等待消费者在代理A'处理90条消息。

问题:如何根据消费者的可用性配置网络以平衡消息?

其中一个代理的完整B配置如下。另一个在networkConnector中具有相同的配置,只有不同的名称和IP。

activemq.xml

提前谢谢你!

** 2016年10月25日更新:** 我在http://activemq.apache.org/networks-of-brokers.html

中遇到了以下声明
  

conditionalNetworkBridgeFilterFactory工厂允许速率限制   为目的地指定,以便网络消费者可以   节流。网络消费者的预取在很大程度上被否定了   事实上,网络消费者传递消息通常非常有用   快速,即使预取率低,网络优先级降低   消费者可以挨饿一个适度快速的本地消费者。节流   为此提供了补救措施。

问题:我还不清楚为什么当地消费者A&#39;完成处理最初的10条消息后,经纪人A没有收到B上剩余的80条消息中的任何一条(因为10条被发送给经纪人B的本地消费者)?

我尝试设置更高的<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"> <property name="locations"> <value>file:${activemq.conf}/credentials.properties</value> </property> </bean> <!-- Allows accessing the server log --> <bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery" lazy-init="false" scope="singleton" init-method="start" destroy-method="stop"> </bean> <!-- The <broker> element is used to configure the ActiveMQ broker. --> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker-jms-tux-01-qa-gnd" persistent="false" dataDirectory="${activemq.data}" cacheTempDestinations="false" advisorySupport="true" useJmx="true"> <destinationPolicy> <policyMap> <policyEntries> <policyEntry topic=">" producerFlowControl="true"> <!-- The constantPendingMessageLimitStrategy is used to prevent slow topic consumers to block producers and affect other consumers by limiting the number of messages that are retained For more information, see: http://activemq.apache.org/slow-consumer-handling.html --> <pendingMessageLimitStrategy> <constantPendingMessageLimitStrategy limit="1000"/> </pendingMessageLimitStrategy> <pendingSubscriberPolicy> <vmCursor/> </pendingSubscriberPolicy> </policyEntry> <policyEntry queue=">" producerFlowControl="true" optimizedDispatch="true" queuePrefetch="1" enableAudit="false"> <!-- Allow messages to be replayed back when the broker to which they were forwarded does not have any more consumers. See section "Stuck Messages" from http://activemq.apache.org/networks-of-brokers.html --> <networkBridgeFilterFactory> <!-- N.B.: When using replayWhenNoConsumers=true for versions < 5.9, it is necessary to also disable the cursors duplicate detection using enableAudit=false as the cursor could mark the replayed messages as duplicates (depending on the time window between playing and replaying these messages over the network bridge). The problem is fully explained here: http://tmielke.blogspot.de/2012/03/i-have-messages-on-queue-but-they-dont.html --> <conditionalNetworkBridgeFilterFactory replayWhenNoConsumers="true"/> </networkBridgeFilterFactory> <pendingQueuePolicy> <vmQueueCursor/> </pendingQueuePolicy> <deadLetterStrategy> <sharedDeadLetterStrategy expiration="300000"/> </deadLetterStrategy> </policyEntry> </policyEntries> </policyMap> </destinationPolicy> <!-- The managementContext is used to configure how ActiveMQ is exposed in JMX. By default, ActiveMQ uses the MBean server that is started by the JVM. For more information, see: http://activemq.apache.org/jmx.html --> <managementContext> <managementContext createConnector="true" connectorPort="1099"/> </managementContext> <!-- Network of brokers --> <networkConnectors> <networkConnector name="broker-jms-tux-01-qa-gnd->broker-jms-tux-02-qa-gnd" uri="static:(tcp://10.83.16.22:61616)" conduitSubscriptions="false" dynamicOnly="true" networkTTL="2" alwaysSyncSend="true" decreaseNetworkConsumerPriority="true" duplex="false"/> </networkConnectors> <!-- The systemUsage controls the maximum amount of space the broker will use before disabling caching and/or slowing down producers. For more information, see: http://activemq.apache.org/producer-flow-control.html --> <systemUsage> <systemUsage> <memoryUsage> <memoryUsage percentOfJvmHeap="80"/> </memoryUsage> <storeUsage> <storeUsage limit="10 gb"/> </storeUsage> <tempUsage> <tempUsage limit="4 gb"/> </tempUsage> </systemUsage> </systemUsage> <!-- The transport connectors expose ActiveMQ over a given protocol to clients and other brokers. For more information, see: http://activemq.apache.org/configuring-transports.html --> <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame size to 400MB --> <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=3200000000"/> </transportConnectors> <!-- destroy the spring context on shutdown to stop jetty --> <shutdownHooks> <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook"/> </shutdownHooks> </broker> <!-- Enable web consoles, REST and Ajax APIs and demos The web consoles requires by default login, you can disable this in the jetty.xml file Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details --> <import resource="jetty.xml"/> </beans> ,但它仍无效。

0 个答案:

没有答案