From 7969ce1808c96a87519cb1a3f279287f30637c4b Mon Sep 17 00:00:00 2001 From: Rahib Nazir Butt <39530209+rahibbutt@users.noreply.github.com> Date: Mon, 8 Apr 2024 04:59:16 +0200 Subject: [PATCH] Fixed the code example in README.md for publishing a start message. (#362) --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3e67ab4..a3a135e 100644 --- a/README.md +++ b/README.md @@ -1288,7 +1288,8 @@ const result = await zbc.createProcessInstanceWithResult({ You can publish a message to the Zeebe broker that will be correlated with a running process instance: ```javascript -const { ZBClient, Duration } = require('zeebe-node') +const { ZBClient, Duration } = require('zeebe-node'); +const uuid = require('uuid'); const zbc = new ZBClient() @@ -1333,15 +1334,17 @@ In this case, the correlation key is optional, and all Message Start events that 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): ```javascript -const { ZBClient, Duration } = require('zeebe-node') +const { ZBClient, Duration } = require('zeebe-node'); +const uuid = require('uuid'); -const zbc = new ZB.ZBClient('localhost:26500') +const zbc = new ZBClient('localhost:26500'); zbc.publishStartMessage({ - messageId: uuid.v4(), - name: 'message-name', - variables: { initialProcessVariable: 'here' }, - timeToLive: Duration.seconds.of(10), // seconds -}) + messageId: uuid.v4(), + name: 'message-name', + variables: { initialProcessVariable: 'here' }, + timeToLive: Duration.seconds.of(10), // seconds +}); + ``` 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).