CamundaCon 2023 ― The Process Orchestration Conference of the Year on Sep 27-28

Save your Seat

Camunda External Task Client (Java) 0.1.0-alpha1 Released

  • Blog
  • >
  • Camunda External Task Client (Java) 0.1.0-alpha1 Released
TOPICS

30 Day Free Trial

Bring together legacy systems, RPA bots, microservices and more with Camunda Platform 8

Join the Camunda Developer Newsletter

Get the latest events, release notes, and product updates straight to your mailbox.

TRENDING CONTENT

We are excited to release the first alpha of the Camunda External Task Client (Java).

A Workflow Engine typically calls Service Tasks actively. The Java client allows to break with this principle: remote and
independent Service Task workers continuously fetch tasks, perform the work and share the result with the Workflow Engine
once the work has been done.

The first preview version includes the following features:

  • Complete external tasks
  • Extend the lock duration of external tasks
  • Unlock external tasks
  • Report BPMN errors as well as failures
  • Share primitive and object typed process variables with the Workflow Engine

Example

Let’s consider the following example to get a better understanding of how to use the Java client:

A Workflow of Granting Loans

Firstly, make sure that you have an up and running Camunda Workflow Engine.

Secondly, download and deploy the loan granting workflow to the Camunda Workflow Engine.

Next, create a Maven project and adjust the pom.xml by adding the following Maven coordinates:

<dependency>
  <groupId>org.camunda.bpm</groupId>
  <artifactId>camunda-external-task-client</artifactId>
  <version>0.1.0-alpha1</version>
</dependency>

Then create a main class and add the following lines to it:

// bootstrap the client
ExternalTaskClient client = ExternalTaskClient.create()
  .baseUrl("https://localhost:8080/engine-rest")
  .build();

// subscribe to the topic
client.subscribe("creditScoreChecker")
  .lockDuration(1000)
  .handler((externalTask, externalTaskService) -> {

    // retrieve a variable from the Workflow Engine
    int defaultScore = externalTask.getVariable("defaultScore");

    List<Integer> creditScores = 
      new ArrayList<>(Arrays.asList(defaultScore, 9, 1, 4, 10));

    // create an object typed variable
    ObjectValue creditScoresObject = Variables
      .objectValue(creditScores)
      .create();

    // set the recently created variable
    externalTask.setVariableTyped("creditScores", creditScoresObject);

    // complete the external task
    externalTaskService.complete(externalTask);

    System.out.println("The External Task " + externalTask.getId() 
      + " has been completed!");

  }).open();

Thread.sleep(1000 * 60 * 5);

Finally, run the application. You should see the following output:

The External Task 1d375217-2cfe-11e8-96c2-769e8e30ca9b has been completed!
The External Task 0857150d-2cfe-11e8-96c2-769e8e30ca9b has been completed!
...

Now, you got a quick impression of how to use the Java client and how it behaves. This example can also be found
as a detailed step-by-step guide with all necessary project sources.

Please also see the documentation.

We are reliant on your feedback!
Feel free to share your ideas and suggestions with us in the forum.

Try All Features of Camunda Platform

Related Content

Did you know that you can keep your process instances moving with Operate? Learn how in this tutorial.
Event-streaming technology has many advantages. Learn how your business processes can benefit from using it for process orchestration.
Combining a process orchestration solution like Camunda with an observability solution like Instana can break down silos and help teams better understand their systems.