I use Camunda as bpmn engine in my spring boot application
Main idea: The first process is started in the controller, and after the response is returned to the client, the Second process should start. I do this using @Async(spring framework) to start the second process and I have two bpmn diagrams: firstProcess secondProcess
Simple implementation of the idea:
@RestController
public class SimpleController {
@Autowired
private CustomService asyncService;
@Autowired
private CustomService syncService;
@GetMapping(value = "/request")
public ResponseEntity<String> sendQuestion() {
//start process described in first.bpmn
syncService.startProcess("firstProcess");
//start process described in second.bpmn asynchronously
//controller responses to client without waiting for ending secondProcess
asyncService.startProcess("secondProcess");
return new ResponseEntity<>("OK", HttpStatus.OK);
}
}
@Service
public class AsyncService implements CustomService {
@Autowired
private RuntimeService runtimeService;
@Async
public void startProcess(String key) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
//
}
runtimeService.startProcessInstanceByKey(key);
}
}
Questions: Is there a way to do these two processes in one process (as shown at both processes)? How should I implement this in the spring boot app? bothProcess