Skip to content

Commit 3264920

Browse files
vzicknerfiliphr
authored andcommitted
add plain java example for external worker usage
1 parent 301d36e commit 3264920

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,42 @@ The following properties are for advanced usage. Only change these if you unders
118118
* `flowable.external.worker.number-of-tasks` : The amount of external worker tasks to acquire and lock in one go. The default is `1`.
119119
* `flowable.external.worker.polling-interval` : The amount of time between polling for new external worker jobs. By default, 30 seconds.
120120

121+
122+
## Plain Java
123+
124+
The following dependency needs to be added to start in a plain Java project without Spring Boot:
125+
126+
```xml
127+
<dependency>
128+
<groupId>org.flowable.client</groupId>
129+
<artifactId>flowable-external-worker-client-java</artifactId>
130+
<version>${flowable-worker-client.version}</version>
131+
</dependency>
132+
```
133+
134+
The following is an example Flowable Worker that is retrieving jobs from the `myTopic` topic
135+
136+
```java
137+
ExternalWorkerClient externalWorkerClient = RestExternalWorkerClient.create(
138+
"my-worker",
139+
JavaHttpClientRestInvoker.withBasicAuth("http://localhost:8090/external-job-api", "admin", "test"),
140+
new ObjectMapper()
141+
);
142+
List<AcquiredExternalWorkerJob> jobs = externalWorkerClient.createJobAcquireBuilder()
143+
.topic("myTopic")
144+
.lockDuration(Duration.ofMinutes(1L))
145+
.acquireAndLock();
146+
147+
for (AcquiredExternalWorkerJob job : jobs) {
148+
System.out.println("Executed job: " + job.getId());
149+
externalWorkerClient.createCompletionBuilder(job)
150+
.complete();
151+
}
152+
```
153+
154+
### Authentication
155+
156+
There are two ways that the application can be authenticated with a Flowable installation:
157+
158+
* Using HTTP Basic authentication with a provided username and password, as shown in the example above.
159+
* Using HTTP Bearer authentication with a provided access token. In this case the `RestInvoker` can be created like this: `JavaHttpClientRestInvoker.withAccessToken("http://localhost:8090/external-job-api", "<your-access-token>")`

0 commit comments

Comments
 (0)