2

How to create automatic shutdown in spring integration after finish all process for all files?

My application download undefined number of files and process all files sequentially, the flow is like this:

file:inbound-channel-adapter --> Transformer --> Splitter -->
http-outbound-gateway --> int:aggregator --> mail:outbound-channel-adapter.

At the End, i should shutdown my app.

How to know that all files are processed? Anyone has an experience about it ?

Thanks

NAZEHA
  • 455
  • 9
  • 24

1 Answers1

1

In you case you need to track your inbound directory. You have to add another step to your flow (probably to track the last file). I would suggest an ETL technique: Read file descriptions then process them.

When it will be processed you can send event to shutdown the app.

Spring boot application can be stopped by using ConfigurableApplicationContext:

SpringApplication app = new SpringApplication(Application.class);
ConfigurableApplicationContext context = app.run(args);
context.close();

Also there is another way using Spring Actuator shutdown endpoint: See How to shutdown a Spring Boot Application in a correct way?

Spring Boot documentation

Community
  • 1
  • 1
Anton N
  • 2,317
  • 24
  • 28