npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@digitaltg/gnspd-camunda-external-task-client-js

v1.1.1

Published

Implement your [BPMN Service Task](https://docs.camunda.org/manual/latest/user-guide/process-engine/external-tasks/) in NodeJS.

Readme

Note: this is a customized version of camunda-external-task-client-js, available on the following GitHub repository: https://github.com/camunda/camunda-external-task-client-js

@digitaltg/gnspd-camunda-external-task-client-js

npm version CI

Implement your BPMN Service Task in NodeJS.

This package is an ECMAScript module (ESM) and provides no CommonJS exports.

NodeJS >= v18 is required

Installing

npm install -s @digitaltg/gnspd-camunda-external-task-client-js

Or:

yarn add @digitaltg/gnspd-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:
import { Client, logger } from "@digitaltg/gnspd-camunda-external-task-client-js";

// Configuration for the Client:
//  - 'baseUrl': URL to the Process Engine
//  - 'useRabbitMQ': Enable RabbitMQ integration
//  - 'rabbitMQ': RabbitMQ settings
//    - 'url': Connection URL for RabbitMQ
//    - 'exchange': Exchange name for Camunda communication
//    - 'onTaskPushed': Callback when a task is pushed
//    - 'onTaskFail': Callback when a task fails
//  - 'use': Utility to automatically log important events

const config = {
  baseUrl: "http://172.24.208.1:8080/engine-rest",
  useRabbitMQ: true,
  rabbitMQ: {
    url: "amqp://localhost:5672",
    exchange: "camunda-exchange",
    onTaskPushed: (task) => {
      console.log(task);
    },
    onTaskFail: (error) => {
      console.log(error);
    },
  },
  use: logger,
};

Note: If useRabbit is enabled (true), there's no need to perform a subscribe, as all tasks will be sent to the RabbitMQ queue. All you need to do is specify the desired topic.

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);
});

[consumer rabbitMQ] The consumer listens to RabbitMQ queue “camunda-tasks” bound to “exchange name to process Camunda external tasks sent through AMQP protocol

import amqp from "amqplib";

const config = {
  url: "amqp://localhost:5672",
  exchange: "camunda-exchange",
  queue: "camunda-tasks",
};

async function startConsumer() {
  try {
    // connect to RabbitMQ
    const connection = await amqp.connect(config.url);

    // Create a communication channel
    const channel = await connection.createChannel();

    // Declaration of exchange in “direct” mode
    await channel.assertExchange(config.exchange, "direct", {
      durable: true,
    });

    // Queue declaration
    await channel.assertQueue(config.queue, {
      durable: true,
    });

    // Link the queue to the exchange using the “task” routing key
    await channel.bindQueue(config.queue, config.exchange, "task");

    await channel.consume(config.queue, async (msg) => {
      if (msg !== null) {
        try {
          // Extract message data
          const taskData = JSON.parse(msg.content.toString());

          // Confirms receipt and processing of message
          channel.ack(msg);
          console.log("✅ Message traité et acquitté");
        } catch (error) {
          console.error("❌ Erreur lors du traitement du message:", error);

          // Requeues the message for a new attempt
          channel.nack(msg, false, true);
        }
      }
    });

  } catch (error) {
    console.error("❌ Erreur de connexion:", error);
    process.exit(1);
  }
}

Note: : channel.ack(msg) - Permanently removes the message from the queue - Use when the message has been fully processed without error and you want to remove the message from the queue. channel.nack(msg) - Use if you want to return the message to the queue.

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

import { Variables } from "@digitaltg/gnspd-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.