Code Monkey home page Code Monkey logo

camunda-worker-node's Introduction

camunda-worker-node

Implement external task workers for Camunda BPM in NodeJS.

Compatible with Camunda BPM 7.5+.

Summary

This library provides you with a simple API to implement external tasks for the Camunda process engine with NodeJS.

var Workers = require('camunda-worker-node');

var engineEndpoint = 'http://localhost:8080/engine-rest';

var workers = Workers(engineEndpoint, {
  workerId: 'some-worker-id'
});

// a worker may access request, access and modify process variables
workers.registerWorker('work:A', [ 'numberVar' ], function(context, callback) {

  var newNumber = context.variables.numberVar + 1;

  // node style callback (err, result)
  callback(null, {
    variables: {
      numberVar: newNumber
    }
  });
});

// a worker can handle errors, too
workers.registerWorker('work:B', function(context, callback) {

  // report an error, if things go awry
  callback(new Error('no work done'));
});


// shutdown the workers instance with the application
workers.shutdown();

Make sure you defined the external tasks in the process diagram before:

<bpmn:serviceTask
        id="Task_A"
        camunda:type="external"
        camunda:topicName="work:A" />

Extend Workers

Workers may be extended via the use config parameter.

Workers(engineEndpoint, {
  use: [
    Logger,
    Backoff
  ]
});

Existing Extensions

  • Logger - adds verbose logging of what is going on
  • Backoff - increase polling intervals if the engine endpoint is temporarily unavailable

Dynamically Unregister a Worker

It is possible to dynamically unregister a worker any time.

var worker = workers.registerWorker('someTopic', function(context, callback) {
  // do work
  callback(null);
});

// later
worker.remove();

Installation

npm i --save camunda-worker-node

Develop

npm install
npm test

Hint: You need a Camunda BPM REST API exposed on localhost:8080/engine-rest for the tests to pass. An easy way to get it up running is via Docker.

License

MIT

camunda-worker-node's People

Contributors

iftekharulislam avatar nikku avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.