英文:
How to catch AuthenticationFailedException that appeared in ImapMailReceiver
问题
private IntegrationFlowRegistration getIntegrationFlowRegistration(){
IntegrationFlow flow = IntegrationFlows
.from(Mail.imapIdleAdapter(createImapMailReceiver(imapUrl))
.autoStartup(true)
)
.handle(System.out::println)
.get();
return this.flowContext.registration(flow).register();
}
我为不同的客户动态创建IntegrationFlowRegistration,有时候凭据是不正确的。我想捕捉AuthenticationFailedException并将其记录,但找不到方法来捕捉它。请您能否给我一个提示,说明如何实现?我已阅读了DSL文档,但未找到相应的方法或示例。
英文:
private IntegrationFlowRegistration getIntegrationFlowRegistration(){
IntegrationFlow flow = IntegrationFlows
.from(Mail.imapIdleAdapter(createImapMailReceiver(imapUrl))
.autoStartup(true)
)
.handle(System.out::println)
.get();
return this.flowContext.registration(flow).register();
}
I create dynamically IntegrationFlowRegistration for different customers and sometimes credentials are incorrect. I would like to catch AuthenticationFailedException and log it but can't find a way to catch it. Could you please give me a hint of how it can't be done? I read DSL documentation but didn't find a way or good example there.
答案1
得分: 1
添加一个ApplicationListener<ImapIdleExceptionEvent>
bean,或者一个接收该事件类型的@EventListener
方法。
@EventListener
public void imap(ImapIdleExceptionEvent event) {
...
}
从3.0版本开始,IMAP空闲适配器在发生异常时会发出应用程序事件(特别是
ImapIdleExceptionEvent
实例),从而允许应用程序检测并对这些异常采取措施。您可以通过使用<int-event:inbound-channel-adapter>
或配置为接收ImapIdleExceptionEvent或其超类之一的任何ApplicationListener来获取这些事件。
英文:
Add an ApplicationListener<ImapIdleExceptionEvent>
bean, or an @EventListener
method that receives that event type.
@EventListener
public void imap(ImapIdleExceptionEvent event) {
...
}
>Beginning with the 3.0 release, the IMAP idle adapter emits application events (specifically ImapIdleExceptionEvent
instances) when exceptions occur. This allows applications to detect and act on those exceptions. You can obtain the events by using an <int-event:inbound-channel-adapter>
or any ApplicationListener configured to receive an ImapIdleExceptionEvent or one of its super classes.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论