SpringApplicationBuilder: parent-child hierarchy

I have a parent-child architecture for my Spring Boot application, which has a separate child for each configuration file found in the directory.

I am trying to accomplish this using SpringApplicationBuilder and fail.

Currently, my main logic looks something like this:

 SpringApplicationBuilder parentBuilder = new SpringApplicationBuilder(ParentConfiguration.class) .properties(Collections.singletonMap("application.dataTypeCount", propertySourceList.size())) .logStartupInfo(false); // for each property source, add it to a child application and start that application for (PropertySource<?> propertySource : propertySourceList) { parentBuilder .child(ChildConfiguration.class) .initializers(context -> context.getEnvironment().getPropertySources().addLast(propertySource)) .run(args); } 

At the moment it works very well.

However, I do not have the disconnect behavior that I would like. If any of the children does not start, I want each application to stop. What is the best way to achieve this? There seems to be something higher than twirling around with ApplicationEventListener .

0
source share

Source: https://habr.com/ru/post/1271286/


All Articles