Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a reactive CommandLineRunner variant #10116

Closed
bclozel opened this issue Aug 30, 2017 · 1 comment
Closed

Add a reactive CommandLineRunner variant #10116

bclozel opened this issue Aug 30, 2017 · 1 comment
Assignees

Comments

@bclozel
Copy link
Member

@bclozel bclozel commented Aug 30, 2017

See discussion in #9761.

Spring Boot provides a functional interface CommandLineRunner for running tasks.
The method signature works well for blocking operations, but can lead to user errors if it's used with a reactive library.

I've seen a lot of code samples out there just calling Flux.subscribe(Consumer) in a CommandLineRunner.run call — this won't guarantee that the processing of that Flux is done before the application is shut down/the webapp is started.

We could create something like:

@FunctionalInterface
public interface ReactiveCommandLineRunner {
  Mono<Void> run(String... args);
}

We could run all of those in parallel, or, at processing time, we could concat all of them (to guarantee a processing order) and block, like:

firstMono.concatWith(secondMono).then().block();
@bclozel
Copy link
Member Author

@bclozel bclozel commented Sep 1, 2017

Declining this for now - this is more a usability issue about Reactive types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant