Skip to content

Repository files navigation

Community ExtensionCompatible with: Camunda Platform 8

Camunda TaskList Client

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 deprecated, this client is now targeting 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

How to build the client

Spring Boot

Add the dependency to your project:

<dependency>
<groupId>io.camunda</groupId>
<artifactId>spring-boot-starter-camunda-tasklist</artifactId>
<version>${version.tasklist-client}</version>
</dependency>

This client is compatible with the Camunda v2 API. To use it, please configure:

tasklist:
client:
profile: v2

Configure a Camunda Tasklist client with simple authentication:

tasklist:
client:
profile: simple

To adjust the (meaningful) default properties, you can also override them:

tasklist:
client:
profile: simpleenabled: truebase-url: http://localhost:8082session-timeout: PT10Musername: demopassword: demo

Configure a Camunda Tasklist client with identity authentication:

tasklist:
client:
profile: oidcclient-id:
client-secret:
scope: # optional

To adjust the (meaningful) default properties, you can also override them:

tasklist:
client:
profile: oidcenabled: truebase-url: http://localhost:8082auth-url: http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/tokenaudience: tasklist-apiclient-id:
client-secret:
scope: # optional

Configure a Camunda Tasklist client for Saas:

tasklist:
client:
profile: saasregion:
cluster-id:
client-id:
client-secret:
tasklist:
client:
profile: saasenabled: truebase-url: https://${tasklist.client.region}.tasklist.camunda.io/${tasklist.client.cluster-id}auth-url: https://login.cloud.camunda.io/oauth/tokenaudience: tasklist.camunda.ioregion:
cluster-id:
client-id:
client-secret:

Configure defaults that influence the client behavior:

tasklist:
client:
defaults:
load-truncated-variables: truereturn-variables: trueuse-zeebe-user-tasks: truetenant-ids:
- <default>

Plain Java

Add the dependency to your project:

<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-tasklist-client-java</artifactId>
<version>${version.tasklist-client}</version>
</dependency>

Build a Camunda Tasklist client with simple authentication:

// properties you need to provideApiVersionapiVersion = ApiVersion.v1;
Stringusername = "demo";
Stringpassword = "demo";
URLtasklistUrl = URI.create("http://localhost:8082").toURL();
booleanreturnVariables = false;
booleanloadTruncatedVariables = false;
booleanuseZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as wellCamundaClientcamundaClient = camundaClient();
// bootstrappingSimpleCredentialcredentials =
newSimpleCredential(username, password, tasklistUrl, Duration.ofMinutes(10));
SimpleAuthenticationauthentication = newSimpleAuthentication(credentials);
CamundaTasklistClientConfigurationconfiguration =
newCamundaTasklistClientConfiguration(
apiVersion,
authentication,
tasklistUrl,
camundaClient,
newDefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClientclient = newCamundaTaskListClient(configuration);

Build a Camunda Tasklist client with identity authentication:

// properties you need to provideApiVersionapiVersion = ApiVersion.v1;
StringclientId = "";
StringclientSecret = "";
Stringaudience = "tasklist-api";
Stringscope = ""; // can be omitted if not requiredURLtasklistUrl = URI.create("http://localhost:8082").toURL();
URLauthUrl =
URI.create(
"http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token")
.toURL();
booleanreturnVariables = false;
booleanloadTruncatedVariables = false;
booleanuseZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as wellCamundaClientcamundaClient = camundaClient();
// bootstrappingJwtCredentialcredentials =
newJwtCredential(clientId, clientSecret, audience, authUrl, scope);
ObjectMapperobjectMapper = newObjectMapper();
TokenResponseHttpClientResponseHandlerclientResponseHandler =
newTokenResponseHttpClientResponseHandler(objectMapper);
JwtAuthenticationauthentication = newJwtAuthentication(credentials, clientResponseHandler);
CamundaTasklistClientConfigurationconfiguration =
newCamundaTasklistClientConfiguration(
apiVersion,
authentication,
tasklistUrl,
camundaClient,
newDefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClientclient = newCamundaTaskListClient(configuration);

Build a Camunda Tasklist client for Saas:

// properties you need to provideApiVersionapiVersion = ApiVersion.v1;
Stringregion = "";
StringclusterId = "";
StringclientId = "";
StringclientSecret = "";
booleanreturnVariables = false;
booleanloadTruncatedVariables = false;
booleanuseZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using camunda user tasks, you require a camunda client as wellCamundaClientcamundaClient = camundaClient();
// bootstrappingURLtasklistUrl =
URI.create("https://" + region + ".tasklist.camunda.io/" + clusterId).toURL();
URLauthUrl = URI.create("https://login.cloud.camunda.io/oauth/token").toURL();
JwtCredentialcredentials =
newJwtCredential(clientId, clientSecret, "tasklist.camunda.io", authUrl, null);
ObjectMapperobjectMapper = newObjectMapper();
TokenResponseHttpClientResponseHandlerclientResponseHandler =
newTokenResponseHttpClientResponseHandler(objectMapper);
JwtAuthenticationauthentication = newJwtAuthentication(credentials, clientResponseHandler);
CamundaTasklistClientConfigurationconfiguration =
newCamundaTasklistClientConfiguration(
apiVersion,
authentication,
tasklistUrl,
camundaClient,
newDefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClientclient = newCamundaTaskListClient(configuration);

ℹ️ 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.

Make some queries

//get tasks from a process instance (TaskSearch can take many more parameters)TaskSearchts = newTaskSearch().setProcessInstanceKey("2251799818839086");
TaskListtasksFromInstance = client.getTasks(ts);
//get tasks from process variablests = newTaskSearch().addVariableFilter("riskLevels", List.of("yellow", "yellow")).addVariableFilter("age", 30);
TaskListtasksFromVariableSearch = client.getTasks(ts);
//get tasks assigned to demoTaskListtasks = client.getAssigneeTasks("demo", TaskState.CREATED, null);
for(Tasktask : 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 taskstasks = client.getTasks(false, null, null);
for(Tasktask : tasks) {
//assign task to paulclient.claim(task.getId(), "paul");
}
for(Tasktask : tasks) {
//complete task with variablesclient.completeTask(task.getId(), Map.of("key", "value"));
}
//get a single tasktask = client.getTask("1");
//get form schemaStringformKey = task.getFormKey();
StringformId = formKey.substring(formKey.lastIndexOf(":")+1);
StringprocessDefinitionId = task.getProcessDefinitionId();
Formform = client.getForm(formId, processDefinitionId);
Stringschema = form.getSchema();

Note

A similar library is available for the Operate API of Camunda Platform here: camunda-operate-client-java

About

Java client for the Tasklist API of Camunda Platform 8

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages