I have an application with Java and Spring on the server side. This server has several modules, and one of them is responsible for the execution of one process. One of the modules has a process that starts at one of the endpoints and has several steps.
Something like that:
@RestController
@AllArgsConstructor
@RequestMapping(value = "movie")
public class MovieController {
private final MovieService movieService;
@GetMapping("step1")
public ResponseEntity step1() {
return movieService.step1();
}
@GetMapping("step2")
public ResponseEntity step2() {
return movieService.step2();
}
@GetMapping("step3")
public ResponseEntity step3() {
return movieService.step3();
}
@GetMapping("step4")
public ResponseEntity step4() {
return movieService.step4();
}
@GetMapping("step5")
public ResponseEntity step5() {
return movieService.step5();
}
}
As you can see, each step can be launched from the user interface in this case. But now I need to add the ability to run all the steps from one endpoint. All steps depend on the state of the previous step, and the next step should never be started if the previous one was unsuccessful. That is why I am looking for the best way to complete all the steps.
I do not like it:
@PostMapping("run")
public ResponseEntity runProcess() {
movieService.step1();
movieService.step2();
movieService.step3();
movieService.step4();
return movieService.step5();
}
Spring Batch, movieService
Spring ?
?