Complete task through Spring Boot without REST

Start note: I have little experience with Java and am new with Spring Boot and Camunda 7.

I am trying to make a Spring Boot (v2.6.7) backend system which handles the business logic of the whole application and embed Camunda (v7.17.0) to handle the specific path for the process that an application goes through.

To make an application the frontend sends an HTTP request to Spring Boot which starts an instance in the process. The instance id gets saved in the MySQL database by Spring Boot to be able to link the data of an application with the instance created in Camunda, and in the process the applicationId in MySQL will also be put in the camunda forms by Spring Boot.

I was wondering how Spring Boot can tell Camunda to complete a task while (sometimes) providing extra data required in the camunda form at the task. Since Camunda is embedded this shouldn’t go through REST.
And how should I model it in the Camunda Modeler? Currently I have put user tasks on all tasks which Spring Boot should ‘manually’ trigger.

At this moment I have made an HTTP request in Spring Boot from which a process is started by calling it in RuntimeService. (I start it from a message start event since I have multiple)

        ProcessInstance instance = runtimeService.startProcessInstanceByMessage("fieldManagerStart");

I save the instanceId from this ProcessInstance in MySQL. The next step I want to take is complete the next task for which I have to provide an id which I have saved in the Application entity in the database. How can I do this?

EDIT: Another question, are you able to get the name of the task the instance is currently at? I would like to show the current task (and perhaps the history) in my own ReactJS frontend.

hey @Volkan343, if you want to query for your user tasks, complete them, etc, you should be using the TaskService bean that comes within the camunda engine library.

private final TaskService taskService;

You can query by task assignee, by process instance id and many other parameters to get a list of tasks:

List<Task> tasks = taskService.createTaskQuery()

if you want to complete a task and set variables to the process this is the way:

Map<String, Object> variables = new HashMap<>();
        taskService.complete(tasks.get(0).getId(), variables);

Thank you for the information, it helped me a long way.

From the Task I can get the Camunda Form Ref with which I’d like to get the fields which have to be filled in to be able to complete the task.
Currently I’m using FormService to getTaskFormData, but this only gives me the data that I’ve filled in, in previous task completions.
How can I get the fields with which I can complete the current task?