pom.xml file:
Requirements
External Task Client Spring Boot Starter requires Java 17.Topic Subscription
The interface which allows implementing the custom business logic and interacting with the Engine is calledExternalTaskHandler. A subscription is identified by a topic name and configured with a
reference to the ExternalTaskHandler bean.
You can subscribe the Client to the topic name creditScoreChecker by defining a bean with the return
type ExternalTaskHandler and annotate this bean with:
application.yml file:
application.yml file always overrides the respective attribute defined programmatically via annotation.
Handler Configuration Example
Please consider the following complete handler bean example:Open/close a Topic Subscription
When not further configured, a topic subscription is automatically opened when the Spring Boot application starts, meaning the Client starts immediately to fetch External Tasks related to the topic name. There might be situations in which a topic subscription should not be opened immediately when the application starts. You can control this via theauto-open flag.
The interface SpringTopicSubscription allows you to open or close a topic programmatically as soon
as the subscription has been initialized. The initialization process is triggered as soon as the
application is started.
When the subscription has been initialized, a SubscriptionInitializedEvent is emitted, and the
topic subscription can be opened or closed:
Configuration
application.yml file
The central configuration point is the application.yml file.
Client Bootstrapping
Please make sure to configure the properties together with the prefix:camunda.bpm.client
An example configuration could look as follows:
| Property name | Description | Default value |
|---|---|---|
base-url | Mandatory: Base url of the ASEE Flow Runtime REST API. | |
worker-id | A custom worker id the Workflow Engine is aware of. Note: make sure to choose a unique worker id. | hostname + 128 bit UUID |
max-tasks | Specifies the maximum number of tasks that can be fetched within one request. | 10 |
use-priority | Specifies whether tasks should be fetched based on their priority or arbitrarily. | true |
use-create-time | Specifies whether tasks should be fetched based on their create time in descending order. Use this property in disjunction with order-by-create-time property or a SpringExternalTaskClientException will be thrown. | false |
order-by-create-time | Specifies whether tasks should be fetched based on their createTime with the given configured order. It can be either “asc” or “desc”. Use this property in disjunction with use-create-time property or a SpringExternalTaskClientException will be thrown. | null |
async-response-timeout | Asynchronous response (long polling) is enabled if a timeout is given. Specifies the maximum waiting time for the response of fetched and locked External Tasks. The response is performed immediately if External Tasks are available at the moment of the request. | null |
disable-auto-fetching | Disables immediate fetching for external tasks after bootstrapping the Client. To start fetching ExternalTaskClient#start() must be called. | false |
disable-backoff-strategy | Disables the client-side backoff strategy. When set to true, a BackoffStrategy bean is ignored.Heads-up: Please bear in mind that disabling the client-side backoff can lead to heavy load situations on the engine side. To avoid this, please specify an appropriate async-response-timeout. | false |
lock-duration | Specifies for how many milliseconds an External Task is locked. Must be greater than zero. It is overridden by the lock duration configured on a topic subscription | 20,000 |
date-format | Specifies the date format to de-/serialize date variables. | yyyy-MM-dd’T’HH:mm:ss.SSSZ |
default-serialization-format | Specifies the serialization format that is used to serialize objects when no specific format is requested. | application/json |
basic-auth.username | Specifies the username credential of the REST API to be authenticated with. | |
basic-auth.password | Specifies the password credential of the REST API to be authenticated with. |
Topic Subscription
The properties for topic subscriptions go under:camunda.bpm.client.subscriptions
The configuration properties can be applied for each topic name as follows:
| Property name | Description | Default value |
|---|---|---|
${TOPIC_NAME} | The Service Task’s topic name in the BPMN process model the Client subscribes to. | |
auto-open | When false, topic subscription can be opened after the application starts calling SpringTopicSubscription#open(). Otherwise, the Client immediately starts to fetch for External Tasks. | true |
lock-duration | Specifies for how many milliseconds an External Task is locked. Must be greater than zero. Overrides the lock duration configured on bootstrapping the Client. | 20,000 |
variable-names | Variable names of variables that are supposed to be retrieved. All variables are retrieved by default. | null |
local-variables | Whether or not variables from greater scope than the External Task should be fetched. When false, all variables visible in the scope will be fetched. When true, only local variables to the scope of the External Task will be fetched. | false |
include-extension-properties | Whether or not to include custom extension properties for fetched External Tasks. When true, all extensionProperties defined in the External Service Task will be provided. When false, extensionProperties defined in the External Service Task will be ignored. | false |
business-key | Only External Tasks related to the specified business key are fetched. | |
process-definition-id | Only External Tasks related to the specified process definition id are fetched. | |
process-definition-id-in | Only External Tasks related to the specified list of process definition ids are fetched. List of ids have logical OR semantic. | |
process-definition-key | Only External Tasks related to the specified process definition key are fetched. | |
process-definition-key-in | Only External Tasks related to the specified list of process definition keys are fetched. List of keys have logical OR semantic. | |
process-definition-version-tag | Only External Tasks related to the specified process definition version tag are fetched. | |
process-variables | Only External Tasks related to the specified map of process variables (key: variable name, value: variable value) are fetched. Map of variables have logical OR semantic. | |
without-tenant-id | Only External Tasks without a tenant id are fetched. | |
tenant-id-in | Only External Tasks related to the specified list of tenant ids are fetched. List of ids have logical OR semantic. |
Logging
To log the Client’s internal workings, you can set the level of the loggerorg.camunda.bpm.client.spring to DEBUG.
You can set the log level in your application.yml file as follows:
org.camunda.bpm.client as well.
Request Interceptor
A request interceptor is called whenever the Client performs an HTTP request. You can use this extension point, for example, to implement a custom authentication strategy like OAuth 2.0. You can register one or more request interceptors by defining beans of typeClientRequestInterceptor:
Backoff Strategy
By default, the Client uses an exponential backoff strategy. You can replace it with a custom strategy by defining a bean of typeBackoffStrategy:
Resolving Properties
String-based Client configuration properties can be resolved from a custom properties file by defining a bean of typePropertySourcesPlaceholderConfigurer:
client.properties file as follows:
application.yml file:
Custom Client
You can bootstrap the Client programmatically, which skips the internal creation of the Client:Beans
You can define handler beans, but more beans are defined internally, and they are beyond your control. However, these beans can be accessed via auto wiring.Client Bean
When not already defined by the user (see Custom Client), a bean with the nameexternalTaskClient of type ExternalTaskClient is constructed.
Subscription Bean
Based on a handler bean annotated with@ExternalTaskSubscription, a subscription bean of type
SpringTopicSubscription is constructed. The bean name is composed of:
Spring-only Module
If you want to use Spring instead of Spring Boot, you can add the following Maven dependency to yourpom.xml file:
@EnableExternalTaskClient. You can find all
configuration attributes in the
Javadocs.