我有jdbc:inbound-channel-adapter轮询50条记录。 我试图通过将pollerExecutor池大小缩放到1-10来提高性能,以便多个线程可以处理50条记录:
<int-jdbc:inbound-channel-adapter
id="initial.ContactType.poller"
query="${poller.ContactType.get}"
max-rows="${poller.deliveryContactType.maxRow:50}"
row-mapper="ContactTypePollerRowMapper"
data-source="dataSource" channel="ContactTypeChannel">
<int:poller fixed-rate="3000" time-unit="MILLISECONDS" task-executor="pollerExecutor">
<int:advice-chain>
<ref bean="pollerLoggingAdvice"/>
<ref bean="txAdvice" />
</int:advice-chain>
</int:poller>
</int-jdbc:inbound-channel-adapter>
<task:executor id="pollerExecutor" pool-size="1-10"
queue-capacity="0" rejection-policy="CALLER_RUNS" />
我测试了处理100,000条记录所花费的时间是相同的,而不管池的大小如何。
我进行了三轮测试,分别是pool-size = 1,pool-size = 1-3和pool-size = 1-10, 在所有三个测试中,每次100,000条记录都需要1个小时。
我通过检查日志确认pollerExecutor线程不能并行运行。 在pollerExecutor-2开始处理之前,pollerExecutor-1会处理所有50条记录。
为什么container / pollerExecutor无法并行运行?