You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+21-3
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ This is a Node.js gRPC client for [Zeebe](https://zeebe.io). It is written in Ty
7
7
8
8
Comprehensive API documentation is available [online](https://creditsenseau.github.io/zeebe-client-node-js/) and in the `docs` subdirectory.
9
9
10
+
Docker-compose configurations for Zeebe are available at [https://github.com/zeebe-io/zeebe-docker-compose](https://github.com/zeebe-io/zeebe-docker-compose).
11
+
10
12
## Versioning
11
13
12
14
NPM Package version 1.x.x supports Zeebe 0.15/0.16.
To complete a task, the task worker handler function receives a `complete` method. This method has a `success` and a `failure` method (as well as being able to be called directly). Calling the method directly - `complete()` is the same as calling `complete.success()`.
131
+
132
+
Call `complete.success()` (or just `complete()`) passing in a optional plain old JavaScript object (POJO) - a key:value map. These are variable:value pairs that will be used to update the workflow state in the broker.
133
+
134
+
Call `complete.failure()` to fail the task. You must pass in a string message describing the failure. The client library decrements the retry count, and the broker handles the retry logic. If the failure is a hard failure and should cause an incident to be raised in Operate, then pass in `0` for the optional second parameter, `retries`:
135
+
136
+
```javascript
137
+
complete.failure('This is a critical failure and will raise an incident', 0)
138
+
```
139
+
126
140
### Start a Workflow Instance
127
141
128
142
```javascript
@@ -162,9 +176,9 @@ zbc.publishMessage({
162
176
```
163
177
164
178
You can also publish a message targeting a [Message Start Event](https://github.com/zeebe-io/zeebe/issues/1858).
165
-
In this case, there is no correlation key, and all Message Start events that match the `name` property will receive the message.
179
+
In this case, the correlation key is optional, and all Message Start events that match the `name` property will receive the message.
166
180
167
-
You can use the `publishStartMessage()` method to publish a message with no correlation key (it will be set to `__MESSAGE_START_EVENT__` in the background):
181
+
You can use the `publishStartMessage()` method to publish a message with no correlation key (it will be set to a random uuid in the background):
168
182
169
183
```javascript
170
184
constzbc=newZB.ZBClient('localhost:26500')
@@ -176,6 +190,8 @@ zbc.publishStartMessage({
176
190
})
177
191
```
178
192
193
+
Both normal messages and start messages can be published idempotently by setting both the `messageId` and the `correlationKey`. They will only ever be correlated once. See: [A message can be published idempotent](https://github.com/zeebe-io/zeebe/issues/1012).
194
+
179
195
### Graceful Shutdown
180
196
181
197
To drain workers, call the `close()` method of the ZBClient. This causes all workers using that client to stop polling for jobs, and returns a Promise that resolves when all active jobs have either finished or timed out.
@@ -267,7 +283,7 @@ Integration tests are in the `src/__tests__/integration` directory.
267
283
They require a Zeebe broker to run. You can run them using the [Circle CI CLI](https://circleci.com/docs/2.0/local-cli/):
268
284
269
285
```bash
270
-
circleci local execute -c .circleci/config-local.yml --job test
286
+
circleci local execute -c .circleci/config.yml --job test
271
287
```
272
288
273
289
Or you can start a dockerised broker:
@@ -282,3 +298,5 @@ And then run them manually:
282
298
```bash
283
299
npm run test:integration
284
300
```
301
+
302
+
For the failure test, you need to run Operate ([docker-compose config](https://github.com/zeebe-io/zeebe-docker-compose/blob/master/operate/docker-compose.yml)) and manually verify that an incident has been raised at [http://localhost:8080](http://localhost:8080).
0 commit comments