【问题标题】:Spring Integration Mail Inbound Channel Adapter configured for POP3 access and using a poller configuration hangs after running for some timeSpring Integration Mail Inbound Channel Adapter 配置为 POP3 访问并使用轮询器配置在运行一段时间后挂起
【发布时间】:2017-08-30 18:51:16
【问题描述】:
<int:channel id="emailInputChannel"/>
<!-- Email Poller. Only one poller thread -->   
<task:executor id="emailPollingExecutor" pool-size="1" /> 
<int-mail:inbound-channel-adapter id="pop3EmailAdapter" store-uri="pop3://${pop3.user}:${pop3.pwd}@${pop3.server.host}/Inbox" 
channel="emailInputChannel" should-delete-messages="true" auto-startup="true" java-mail-properties="javaMailProperties">
           <int:poller max-messages-per-poll="1" fixed-delay="${email.poller.delay}" task-executor="emailPollingExecutor"/>
</int-mail:inbound-channel-adapter>
<!-- Java Mail POP3 properties -->
<util:properties id="javaMailProperties">
  <beans:prop key="mail.debug">true</beans:prop> 
  <beans:prop key="mail.pop3.port">${pop3.server.port}</beans:prop> 
</util:properties>

此应用程序轮询包含应用程序文件附件的电子邮件,这些附件包含要处理的数据。电子邮件附件通常每天发送几次,并且相对零星。由于文件包含用于批量加载的数据,因此我们采用了这种配置,为入站 POP3 邮件适配器使用了一个轮询器。拥有多个轮询器会导致重复的轮询器调用来提取同一封电子邮件,而另一个轮询器正在处理它。但是,使用此配置,单个轮询器会在一段时间后挂起,而日志中没有任何问题的迹象。请查看此配置有什么问题。此外,是否有另一种触发电子邮件适配器的方法(例如,定期间隔的 cron 等)?我正在使用 Spring Integration 2.1

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    挂起的轮询器很可能是由于线程卡在用户代码中造成的。我看到你有 mail.debug=true。如果这显示没有活动,则可能是挂起的线程。使用我们的 jstack 进行线程转储。

    是的,您可以使用皇冠表达,但这不太可能改变事情。

    2.1 已经非常老了,但我仍然认为线程挂起是原因。

    【讨论】:

    • 感谢您的回复。当问题出现时,我将尝试捕获线程转储。是否有任何其他解决方案不涉及使用轮询器配置来实现相同的功能。这个应用程序是电子邮件驱动的,电子邮件的频率不是很多。因此,定期启动的 cron 作业(例如每小时一次)可能会起作用。唯一的反面是处理没有及时发生。如果您能想到任何其他替代方案,请告诉我。
    • 根据我的经验,如果轮询停止,则意味着线程卡在用户代码中或某些其他代码已经耗尽了默认调度程序中的线程池。您通常不应该在轮询线程上运行长时间运行的任务;调度器默认只有10个线程,但是can be reconfigured。线程转储将暴露任一条件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多