Will IntegrationFlowContext.remove() destroys currently running IntegrationFlow abruptly?

Viewed 27

Background: I am using Spring Integration to poll 3 mailboxes (outlook365) via InboundChannelAdaper (IMAP). I defined 3 adapters for this. I am using Delayer component as well. Polling is working fine till now.

Problem: Microsoft is going to disable basic authentication soon, so I need to modify this email polling code to use oAuth2 authorization. Oauth2 accessToken expires after some period. I need to keep refresh accessToken at regular intervals.

Solution Attempting: Use dynamic/runtime flow via IntegrationFlowContext, register and remove InboundChannelAdapers ( ie. whole IntegrationFlow ) whenever I get new/refreshed accessToken.

Please assume below scenario:

  1. Existing IntegrationFlows are processing some emails currently or waiting in Delayer to be processed after configured delay of 3 mins.

  2. When I call IntegrationFlowContext.remove() and trying to destroy currently running IntegrationFlow beans, what will happen to those emails are under processing now?

Questions:

  1. Will that running IntegrationFlow ends abruptly and mails under processing will be lost?
  2. Or IntegrationFlowContext will wait for the current process to be completed before destroying IntegrationFlow ?
  3. Is there any other way to use Oauth2 in Spring Integration?

PS: I need to use client-credentials-grant-flow because there is no GUI involved in this client-app described above.

0 Answers
Related