Skip to content

Getting started

Note

If you are using the extension from an application containing Camunda BPM Engine classes on the classpath, please check the Working Example section of our user guide.

Note

You can also use the generated feign clients directly without using the Camunda Services. Please check out the Feign Example section of our user guide.

Install Dependency#

First install the extension dependency and configure Feign and Feign client:

<properties>
  <camunda-platform-7-rest-client-spring-boot.version>7.18.0-SNAPSHOT</camunda-platform-7-rest-client-spring-boot.version>
  <spring-cloud.version>2021.0.5</spring-cloud.version>
</properties>

<dependencyManagement>
<dependencies>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-dependencies</artifactId>
    <version>${spring-cloud.version}</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
  <groupId>org.camunda.community.rest</groupId>
  <artifactId>camunda-platform-7-rest-client-spring-boot-starter</artifactId>
  <version>${camunda-platform-7-rest-client-spring-boot.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
  <groupId>io.github.openfeign</groupId>
  <artifactId>feign-httpclient</artifactId>
</dependency>
</dependencies>

Note

Please make sure your Spring Cloud version matches your Spring Boot version as described in the Spring Cloud documentation

Configuration#

In your client code, activate the usage of REST client by adding the following annotation to your configuration:

@Configuration
@EnableCamundaRestClient
public class MyClientConfiguration {

}

In order to configure the Feign client, make sure to provide usual feign client configuration (e.g. using application.yml). To set up the engine base URL, please set up the properties:

feign:
  client:
    config:
      default:
        url: "http://your-process-engine-host/engine-rest/"

There is also the possibility to configure a different URL for each feign client (even though this is a very uncommon setup):

feign:
  client:
    config:
      processInstance:
        url: "http://your-process-engine-host/engine-rest/"
      processDefinition:
        url: "http://your-process-engine-host/engine-rest/"
      message:
        url: "http://your-process-engine-host/engine-rest/"
      ...

Usage#

To access the remote API, inject the remote API implementation:

@Component
public class MyClient {

  private RuntimeService runtimeService;

  public MyClient(@Qualifier("remote") RuntimeService runtimeService) {
    this.runtimeService = runtimeService;
  }

  public void start() {
    this.runtimeService
      .startProcessInstanceByKey("my_process_key");
  }

  public void correlate() {
    this.runtimeService
      .createMessageCorrelation("message_received")
      .processInstanceBusinessKey("WAIT_FOR_MESSAGE")
      .correlateAllWithResult();
  }
}

Last update: November 18, 2022