Как интегрировать Spring Boot HealthIndicator с электронной почтой для опроса IntegrationFlow с imap?
Я могу получить исключения из IntegrationFlow через errorChannel, но как мне очистить исключение после того, как IntegrationFlow снова начнет работать, например, после сбоя сети.
@SpringBootApplication
public class MyApplication {
@Bean
IntegrationFlow mailFlow() {
return IntegrationFlows
.from(Mail.imapInboundAdapter(receiver()).get(),
e -> e.autoStartup(true)
.poller(Pollers.fixedRate(5000)))
.channel(mailChannel()).get();
}
@Bean
public ImapMailReceiver receiver() {
String mailServerPath = format("imaps://%s:%s@%s/INBOX", mailUser,
encode(mailPassword), mailServer);
ImapMailReceiver result = new ImapMailReceiver(mailServerPath);
return result;
}
@Bean
DirectChannel mailChannel() {
return new DirectChannel();
}
@Autowired
@Qualifier("errorChannel")
private PublishSubscribeChannel errorChannel;
@Bean
public IntegrationFlow errorHandlingFlow() {
return IntegrationFlows.from(errorChannel).handle(message -> {
MessagingException ex = (MessagingException) message.getPayload();
log.error("", ex);
}).get();
}
@Bean
HealthIndicator mailReceiverHealthIndicator() {
return () -> {
/*
* How to error check the imap polling ???
*/
return Health.up().build();
};
}
}