我有一个JMS生成,其生成每秒许多消息,这些消息被发送到AMQ永久队列和由单个消费者,这需要顺序地处理它们被消耗。但看起来制片人比消费者要快得多,而且我有性能和内存问题。消息被拿来非常非常缓慢和消耗似乎发生在区间(消费者的“要求”在投票的方式,这是奇怪的消息?)jms和spring集成的性能问题。以下配置有什么问题?
基本上发生的一切与Spring集成。这是生产者一方的配置。首创股份的消息进来stakesInMemoryChannel,从那里,他们被过滤掷filteredStakesChannel,并从那里,他们会到JMS队列
<bean id="stakesQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg name="name" value="${jms.stakes.queue.name}" />
</bean>
<int:channel id="stakesInMemoryChannel" />
<int:channel id="filteredStakesChannel" >
<int:dispatcher task-executor="taskExecutor"/>
</int:channel>
<bean id="stakeFilterService" class="cayetano.games.stake.StakeFilterService"/>
<int:filter
input-channel="stakesInMemoryChannel"
output-channel="filteredStakesChannel"
throw-exception-on-rejection="false"
expression="true"/>
<jms:outbound-channel-adapter channel="filteredStakesChannel" destination="stakesQueue" delivery-persistent="true" explicit-qos-enabled="true" />
<task:executor id="taskExecutor" pool-size="100" />
其他应用程序消耗(因此发送在单独的线程会发生使用执行人)这样的消息......这些消息来自jms stakesQueue的stakesInputChannel,之后它们被路由到2个独立的频道,一个持续发送消息,另一个做一些其他的事情,让我们称之为“处理”。
<bean id="stakesQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg name="name" value="${jms.stakes.queue.name}" />
</bean>
<jms:message-driven-channel-adapter
channel="stakesInputChannel"
destination="stakesQueue"
acknowledge="auto"
concurrent-consumers="1"
max-concurrent-consumers="1"
/>
<int:publish-subscribe-channel id="stakesInputChannel" />
<int:channel id="persistStakesChannel" />
<int:channel id="processStakesChannel" />
<int:recipient-list-router
id="customRouter"
input-channel="stakesInputChannel"
timeout="3000"
ignore-send-failures="true"
apply-sequence="true"
>
<int:recipient channel="persistStakesChannel"/>
<int:recipient channel="processStakesChannel"/>
</int:recipient-list-router>
<bean id="prefetchPolicy" class="org.apache.activemq.ActiveMQPrefetchPolicy">
<property name="queuePrefetch" value="${jms.broker.prefetch.policy}" />
</bean>
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${jms.broker.url}" />
<property name="prefetchPolicy" ref="prefetchPolicy" />
<property name="optimizeAcknowledge" value="true" />
<property name="useAsyncSend" value="true" />
</bean>
</property>
<property name="sessionCacheSize" value="10"/>
<property name="cacheProducers" value="false"/>
</bean>
我创建JMS用JMeter,它直接将消息发送到ActiveMQ的计划。我发送了更多的消息 - 每20毫秒发送一个消息 - 消费者应用程序正在处理它们,没有任何延迟......所以,问题必须在生产者配置中。 – user358448