Reputation: 1207
I have 2 services that I want to call back to back in a sequential fashion. Neither of them produces any data. What would be the best way to chain them in a webflux pipeline.
I want to call subscribe on the last service call to trigger the whole flow. Something like:
serviceA.methodX()
.then()
serviceB.methodY().subscribe()
Upvotes: 1
Views: 630
Reputation: 1054
Mono<OfSomeThing> executeFirst = ... ;
Mono<OfSomeThing> onceFirstIsCompletedExcecuteSecond = ... ;
Mono<OfSomeThing> plan = executeFirst.then(onceFirstIsCompletedExcecuteSecond);
plan.block();
Upvotes: 0
Reputation: 1207
This is what I figured as an alternative:
Mono.just(Boolean.TRUE)
.flatMap( success -> { serviceA.methodX(); return true; } )
.flatMap( success -> { serviceB.methodY(); return true; } )
.subscribe();
Upvotes: 1