lafual
lafual

Reputation: 785

Run Integration Flow when Spring Boot starts shutdown

I have an Integration flow which logs on to a remote website. The flow then continually POSTs data to a URL. On Spring Boot shutdown, I wish to run a POST which runs a log-out.

Is this possible? I did the following, but the shutdown closes the bean before it can be started.

@PreDestroy
void destroy() { logoutFlow.start(); }

@Bean
StandardIntegrationFlow logoutFlow() {
  return IntegrationFlows
    .from( () -> new GenericMessage<>(""), c -> c.autoStartup(false))
    .handle(
      Http.outboundGateway(url).httpMethod(HttpMethod.POST).expectedResponseType(String.class)
    )
    .log()
    .get();

}

Upvotes: 0

Views: 10

Answers (0)

Related Questions