All Projects → camunda → Camunda External Task Client Js

camunda / Camunda External Task Client Js

Licence: apache-2.0
Implement your BPMN Service Task in NodeJS.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Camunda External Task Client Js

Quinn
Async-friendly QUIC implementation in Rust
Stars: ✭ 1,859 (+1475.42%)
Mutual labels:  hacktoberfest
Kittehircclientlib
An IRC client library in Java
Stars: ✭ 116 (-1.69%)
Mutual labels:  hacktoberfest
React Spring Slider
A slider component for react
Stars: ✭ 118 (+0%)
Mutual labels:  hacktoberfest
Duckstation
Fast PlayStation 1 emulator for x86-64/AArch32/AArch64
Stars: ✭ 2,888 (+2347.46%)
Mutual labels:  hacktoberfest
Smartcrop
smartcrop finds good image crops for arbitrary crop sizes
Stars: ✭ 1,567 (+1227.97%)
Mutual labels:  hacktoberfest
Percona
Development repository for the percona cookbook
Stars: ✭ 117 (-0.85%)
Mutual labels:  hacktoberfest
Fhir
The IBM® FHIR® Server and related projects
Stars: ✭ 117 (-0.85%)
Mutual labels:  hacktoberfest
My Internet Speed
🛎️ Monitor the speed your ISP is delivering
Stars: ✭ 118 (+0%)
Mutual labels:  hacktoberfest
Electronify
👷 The simplest way to build Electron apps.
Stars: ✭ 117 (-0.85%)
Mutual labels:  hacktoberfest
Gatsby Themes
Gatsby themes that we use to build websites at Rocketseat ⚡️🔥
Stars: ✭ 116 (-1.69%)
Mutual labels:  hacktoberfest
Zoid
Cross domain components
Stars: ✭ 1,672 (+1316.95%)
Mutual labels:  hacktoberfest
Kubefed
Kubernetes Cluster Federation
Stars: ✭ 1,955 (+1556.78%)
Mutual labels:  hacktoberfest
Trading Signals
Technical indicators to run technical analysis with JavaScript / TypeScript. 📈
Stars: ✭ 118 (+0%)
Mutual labels:  hacktoberfest
Sentry Php
The official PHP SDK for Sentry (sentry.io)
Stars: ✭ 1,591 (+1248.31%)
Mutual labels:  hacktoberfest
Menu
A JavaScript free menu library for Blazor and Razor Components applications.
Stars: ✭ 118 (+0%)
Mutual labels:  hacktoberfest
Perfil Politico
A platform for profiling public figures in Brazilian politics
Stars: ✭ 117 (-0.85%)
Mutual labels:  hacktoberfest
Git
Development repository for the git cookbook
Stars: ✭ 117 (-0.85%)
Mutual labels:  hacktoberfest
Config Lint
Command line tool to validate configuration files
Stars: ✭ 118 (+0%)
Mutual labels:  hacktoberfest
Node Callofduty
Node Wrapper for the "private" Call Of Duty API.
Stars: ✭ 118 (+0%)
Mutual labels:  hacktoberfest
Drf Api Tracking
Fork of aschn/drf-tracking so that we can maintain and release newer versions
Stars: ✭ 117 (-0.85%)
Mutual labels:  hacktoberfest

camunda-external-task-client

npm version Build Status

Implement your BPMN Service Task in NodeJS.

NodeJS >= v10 is required

Installing

npm install -s camunda-external-task-client-js

Or:

yarn add camunda-external-task-client-js

Usage

  1. Make sure to have Camunda running.
  2. Create a simple process model with an External Service Task and define the topic as 'topicName'.
  3. Deploy the process to the Camunda Platform engine.
  4. In your NodeJS script:
const { Client, logger } = require("camunda-external-task-client-js");

// configuration for the Client:
//  - 'baseUrl': url to the Workflow Engine
//  - 'logger': utility to automatically log important events
const config = { baseUrl: "http://localhost:8080/engine-rest", use: logger };

// create a Client instance with custom configuration
const client = new Client(config);

// susbscribe to the topic: 'creditScoreChecker'
client.subscribe("creditScoreChecker", async function({ task, taskService }) {
  // Put your business logic
  // complete the task
  await taskService.complete(task);
});

Note: Although the examples used in this documentation use async await for handling asynchronous calls, you can also use Promises to achieve the same results.

About External Tasks

External Tasks are service tasks whose execution differs particularly from the execution of other service tasks (e.g. Human Tasks). The execution works in a way that units of work are polled from the engine before being completed.

camunda-external-task-client.js allows you to create easily such client in NodeJS.

Features

Fetch and Lock

Done through polling.

Complete

// Susbscribe to the topic: 'topicName'
client.subscribe("topicName", async function({ task, taskService }) {
  // Put your business logic
  // Complete the task
  await taskService.complete(task);
});

Handle Failure

// Susbscribe to the topic: 'topicName'
client.subscribe("topicName", async function({ task, taskService }) {
  // Put your business logic
  // Handle a Failure
  await taskService.handleFailure(task, {
    errorMessage: "some failure message",
    errorDetails: "some details",
    retries: 1,
    retryTimeout: 1000
  });

});

Handle BPMN Error

// Susbscribe to the topic: 'topicName'
client.subscribe("topicName", async function({ task, taskService }) {
  // Put your business logic

  // Create some variables
  const variables = new Variables().set('date', new Date());

  // Handle a BPMN Failure
  await taskService.handleBpmnError(task, "BPMNError_Code", "Error message", variables);
});

Extend Lock

// Susbscribe to the topic: 'topicName'
client.subscribe("topicName", async function({ task, taskService }) {
  // Put your business logic
  // Extend the lock time
  await taskService.extendLock(task, 5000);
});

Unlock

// Susbscribe to the topic: 'topicName'
client.subscribe("topicName", async function({ task, taskService }) {
  // Put your business logic
  // Unlock the task
  await taskService.unlock(task);
});

Lock

// Susbscribe to the topic: 'topicName'
client.subscribe("topicName", async function({ task, taskService }) {
  // Task is locked by default
  // Put your business logic, unlock the task or let the lock expire

  // Lock a task again
  await taskService.lock(task, 5000);
});

Exchange Process & Local Task Variables

const { Variables } = require("camunda-external-task-client-js");

client.subscribe("topicName", async function({ task, taskService }) {
  // get the process variable 'score'
  const score = task.variables.get("score");

  // set a process variable 'winning'
  const processVariables = new Variables();
  processVariables.set("winning", score > 5);

  // set a local variable 'winningDate'
  const localVariables = new Variables();
  localVariables.set("winningDate", new Date());

  // complete the task
  await taskService.complete(task, processVariables, localVariables);
});

API

Contributing

Have a look at our contribution guide for how to contribute to this repository.

Help and support

License

The source files in this repository are made available under the Apache License Version 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].