如果使用 ImapMailReceiver 将 autoCloseFolder 设置为 false,则手动关闭文件夹

问题描述 投票:0回答:1

阅读 spring-integration-mail 我尝试加载电子邮件的内容,包括附件。结果,我显然设置了autoCloseFolder=false。现在,文档提到 ClosableResource 应该用于在需要时关闭它。但我想知道如何使用 IntegrationFlowContext 实现这种行为?有什么方法可以关闭确定会话结束并关闭文件夹吗?

spring spring-integration spring-integration-dsl spring-integration-mail
1个回答
0
投票

Java Mail API 中没有会话生命周期管理。因此你无法以某种方式捕捉到它的关闭状态。

关闭文件夹挂钩适用于您希望在下一个接收周期重新获取新元数据的用例。但大多数情况下根本不需要关闭它。从 Spring Integration

6.0
开始,当邮箱中没有新邮件需要处理时,文件夹会自动关闭:

        finally {
            if (this.autoCloseFolder || ObjectUtils.isEmpty(messagesToReturn)) {
                closeFolder();
            }
        }
© www.soinside.com 2019 - 2024. All rights reserved.