Reputation: 2192
I am implementing a spring boot app that connects to different imap servers to receive emails. There are lot of imap servers and their number will increase. The app will be run in multiple instances.
I want to use spring integration mail. But I wouldn't like to create an integration flow for each imap server in each instance of app. I am wondering if I can avoid creation of separate integration flow for each imap server? It could be look like: we create one flow that will be run manually (e.g by an event) and this flow would dynamically create needed imap receiver, receive mails and finish.
Is it possible to implement something like that using spring integration mail?
If not and I have to run a separate flow for each imap server on each instance, each flow will probably have to use polling. Does spring integration provide any solution that controls that the same flows of different instances are not run at the same time or controls the polling time of flows of the same sources on different app instances? Maybe there is a load balancer that can control flows on different instances?
Thank you in advance!
Upvotes: 1
Views: 878
Reputation: 121177
I think the dynamic flows registration is an answer for you.
And see this sample: https://github.com/spring-projects/spring-integration-samples/tree/master/advanced/dynamic-tcp-client. It uses TCP/IP for dynamic registration, but you can borrow an idea what you should do for your imap servers and respective IntegrationFlow
to provide mail channel adapters.
Upvotes: 2