消息被删除,从未到达任务执行程序线程

时间:2015-02-25 19:47:02

标签: spring-integration

我今天注意到一个非常奇怪的问题,收到了消息,但它从未被处理过。在下面的配置中,我有5个配置为从JMS队列读取的侦听器,我的窃听记录器打印出已收到JMS消息但是没有任何跟踪由任务执行程序线程处理,其余处理运行正常。在某些时候它只发生了很少的消息。我有以下提供的所有相关配置;任何帮助纠正它将不胜感激。

 <jms:message-driven-channel-adapter                             
                            id="IN1"                                
                            destination="replyQueue"  
                            channel="InChannel" 
                            auto-startup="false" 
                            max-messages-per-task="20"
                            receive-timeout="10000"
                            max-concurrent-consumers="1" 
                            concurrent-consumers="1"                                                            
                            idle-consumer-limit="1"
                            idle-task-execution-limit="1"                               
                            recovery-interval="60000"/>
<jms:message-driven-channel-adapter                                  
                            id="IN2"                                
                            destination="replyQueue"  
                            channel="InChannel" 
                            auto-startup="false" 
                            max-messages-per-task="20"
                            receive-timeout="10000"
                            max-concurrent-consumers="1" 
                            concurrent-consumers="1"                                                            
                            idle-consumer-limit="1"
                            idle-task-execution-limit="1"                               
                            recovery-interval="60000"/>




<int:channel id="InChannel">
<int:dispatcher task-executor="saveTaskExecutor"/>
    <int:interceptors>
        <int:wire-tap channel="MyLogger"/>
    </int:interceptors>
</int:channel>  

Wiretap记录器打印收到的消息。

<int:logging-channel-adapter logger-name="MsgInLogger" id="MyLogger" level="INFO" expression="'received payload for processing'+ payload " />   

任务执行程序的定义如下,我的不足之处在于,它具有无限制的队列,所以没有与消息数量相关的问题,这也是在音量最小时发生的。

<beans:bean id="saveTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<beans:property name="corePoolSize" value="20" />
<beans:property name="maxPoolSize" value="20" />
</beans:bean>  

saveTaskExecutor线程需要花费很长时间来处理一条消息,然后才能接下来,不确定是否有任何超时或到期的事情发生在那里。

1 个答案:

答案 0 :(得分:0)

它们应该没有任何方法可以让它们丢失,但为什么你这样做而不是简单地将concurrent-consumers设置为20并让容器处理你的流量?

你拥有它的方式;如果您的服务器崩溃,您将丢失执行程序队列中的所有消息。您还应该设置acknowledge-mode="transacted"或使用SimpleMessageListenerContainer以避免在服务器崩溃期间丢失进程内消息。