Hello. I trying to create SPA with Spring Boot and Camunda.
I use Camunda starter dependency. I can easily start my process by using RuntimeService, but how can I manage tasks without Cockpit? I want to DemoDelegate do some stuff and then I don’t have to open Cockpit and press " complete" button on task. I tried to use TaskService, but somehow Spring injects null in taskService variable. Need your help. Here is some code:
@SpringBootApplication
@EnableResourceServer
@EnableProcessApplication
public class Main extends SpringBootServletInitializer {
@Autowired
private RuntimeService runtimeService;
public static void main (String[] args) {
SpringApplication.run(Main.class, args);
}
@Override
protected SpringApplicationBuilder configure (SpringApplicationBuilder application) {
return application.sources(Main.class);
}
@EventListener
private void processPostDeploy(PostDeployEvent event) {
runtimeService.startProcessInstanceByKey("Process_1uro4y5");
}
}
@Component
public class DemoDelegate implements JavaDelegate {
TaskService taskService;
@Autowired
public void setTaskService (TaskService taskService) {
this.taskService = taskService;
}
@Override
public void execute (DelegateExecution execution) throws Exception {
System.out.println("First task");
taskService.claim("Activity_1m1jmwo", "demo"); // nullPointer
// some logic here
taskService.complete("Activity_1m1jmwo");
}
}