QueueChannel为什么不简单地增加
concurrent-consumers入站适配器上的属性,而不是使用and轮询器?
<xsd:attribute name="concurrent-consumers" type="xsd:string"> <xsd:annotation> <xsd:documentation>Specify the number of concurrent consumers to create. Default is 1.Raising the number of concurrent consumers is recommended in order to scale the consumption of messages coming infrom a queue. However, note that any ordering guarantees are lost once multiple consumers are registered. Ingeneral, stick with 1 consumer for low-volume queues. </xsd:documentation> </xsd:annotation> </xsd:attribute>
并且,删除
<queue/>和
<poller/>。
另外,我总是建议在日志中包含线程名称(
%t对于log4J);它使调试线程问题变得更加容易。
编辑:
使用轮询器时,线程不足的原因是轮询器的默认
receive-timeout值为1秒。您每50ms调度一个线程,但是每个线程等待
QueueChannel1秒。最终,您的任务队列已满。
为避免这种情况,如果希望继续使用此技术,只需将设置
receive-timeout为
0on,
<poller/>但是在适配器中使用更高的并发效率更高,因为没有轮询或切换到另一个线程。



