This project was intially designed to simplify communication between a java backend and the Camunda 8 task list GraphQL APIs. Since GraphQL APIs are now deprecared, this client is now targetting REST endpoints. Contributions through PR are welcome!
ℹ️ 8.3+ Relesases of this client are generated against Rest endpoints.
ℹ️ 8.3.3.3 changes the way to build authentication and client. Please check the following documentation
Depending on your setup, you may want to use different authentication mechanisms. In case you're using a Camunda Platform without identity enabled, you should use the SimpleAuthentication
SimpleConfig simpleConf = new SimpleConfig();
simpleConf.addProduct(Product.TASKLIST, new SimpleCredential("user", "pwd"));
Authentication auth = SimpleAuthentication.builder().simpleConfig(simpleConf).build();
In case you're using a Self Managed Camunda Platform with identity enabled (and Keycloak), you should use the SelfManagedAuthentication
JwtConfig jwtConfig = new JwtConfig();
jwtConfig.addProduct(Product.TASKLIST, new JwtCredential("clientId", "clientSecret", null, null));
Authentication auth = SelfManagedAuthentication.builder().jwtConfig(jwtConfig).build();
And finally, if you're using a SaaS environment, just use the SaaSAuthentication
JwtConfig jwtConfig = new JwtConfig();
jwtConfig.addProduct(Product.TASKLIST, new JwtCredential("clientId", "clientSecret", "tasklist.camunda.io", "https://login.cloud.camunda.io/oauth/token"));
Authentication auth = SaaSAuthentication.builder().jwtConfig(jwtConfig).build();
Simply build a CamundaTaskListClient that takes an authentication and the tasklist url as parameters.
CamundaTaskListClient client = CamundaTaskListClient.builder().taskListUrl("http://localhost:8081").shouldReturnVariables().shouldLoadTruncatedVariables().authentication(auth).build();
ℹ️ Since the SelfManagedAuthentication and the SaaSAuthentication are a bit complex, two helpers have been added to the builder saaSAuthentication(clientId, clientSecret) and selfManagedAuthentication(clientId, clientSecret, keycloakUrl)
ℹ️ shouldReturnVariables() will read variables along with tasks. This is not the recommended approach but rather a commodity. In real project implementation, we would recommend to load task variables only when required.
ℹ️ shouldLoadTruncatedVariables() will execute a second call to read the variable if its value was truncated in the initial search.
//get tasks from a process instance (TaskSearch can take many more parameters)
TaskSearch ts = new TaskSearch().setProcessInstanceId("2251799818839086");
TaskList tasksFromInstance = client.getTasks(ts);
//get tasks from process variables
ts = new TaskSearch().addVariableFilter("riskLevels", List.of("yellow", "yellow")).addVariableFilter("age", 30);
TaskList tasksFromVariableSearch = client.getTasks(ts);
//get tasks assigned to demo
TaskList tasks = client.getAssigneeTasks("demo", TaskState.CREATED, null);
for(Task task : tasks) {
client.unclaim(task.getId());
}
//get tasks associated with group "toto"
tasks = client.getGroupTasks("toto", null, null);
//get 10 completed tasks without their variables (last parameter) associated with group "toto", assigned (second parameter) to paul (thrid parameter)
tasks = client.getTasks("toto", true, "paul", TaskState.COMPLETED, 10, false);
//navigate after, before, afterOrEqual to previous result.
tasks = client.after(tasks);
tasks = client.before(tasks);
tasks = client.afterOrEqual(tasks);
//get unassigned tasks
tasks = client.getTasks(false, null, null);
for(Task task : tasks) {
//assign task to paul
client.claim(task.getId(), "paul");
}
for(Task task : tasks) {
//complete task with variables
client.completeTask(task.getId(), Map.of("key", "value"));
}
//get a single task
task = client.getTask("1");
//get form schema
String formKey = task.getFormKey();
String formId = formKey.substring(formKey.lastIndexOf(":")+1);
String processDefinitionId = task.getProcessDefinitionId();
Form form = client.getForm(formId, processDefinitionId);
String schema = form.getSchema();
You can import it to your maven or gradle project as a dependency
<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-tasklist-client-java</artifactId>
<version>8.4.0.3</version>
</dependency>
A similar library is available for operate there: java-client-operate