GithubHelp home page GithubHelp logo

nikku / camunda-worker-node Goto Github PK

View Code? Open in Web Editor NEW
49.0 4.0 30.0 306 KB

Implement your external task workers for Camunda in NodeJS.

Home Page: https://www.npmjs.com/package/camunda-worker-node

License: MIT License

JavaScript 100.00%
camunda external-task workers

camunda-worker-node's People

Contributors

iftekharulislam avatar j12934 avatar nikku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

camunda-worker-node's Issues

Custom result variable encoding types

Hi!
First of all thank you for this package! ๐Ÿ˜‰

I have unfortunately run into a use case in which I need more direct control on the type and serialization format of the result variables submitted by the worker function.

I'd like to add functionality to manually add type and serialization information to a result variable.

I'm currently thinking that it should look something like this:

var Worker = require('camunda-worker-node');
var ManualSerialization = require('camunda-worker-node/lib/manual-serialization');

// ...

worker.subscribe('work:A', [], async function(context) {
    return {
        variables: {
            customVar: new ManualSerialization({
                value: '"foobar"',
                type: 'Object',
                valueInfo: {
                    objectTypeName: 'java.lang.String',
                    serializationDataFormat: 'application/json',
                },
            }),
        },
    };
});

The object passed into the ManualSerialization class would then get directly passed into the external task completion request without any magic.

Would this be a good addition or is there a better way to support this?

Import fails in ReactJS project created by CRA

Failed to compile.

./node_modules/camunda-worker-node/lib/worker.js
Module parse failed: Unexpected token (453:4)
You may need an appropriate loader to handle this file type.
|
|   this.options = {
|     ...this.options,
|     ...newOptions
|   };

cannot set new variable wihtin a Service Task

Hi nikku,
I cannot get my head arround, how to set a new variable in a Servcie Task, so that I can use this variable later in a Gateway Output.
Any ideas how to do that with Camunda-Worker-Node?

How can I prevent the completion of a task?

hi @nikku,
Thank you for sharing this excellent lib.
Though, going through your samples, is not clear to me how can I "skip" a task for being completed:

workers.registerWorker('work:A', [ 'numberVar' ], async function(context) {
  
  // let say, my business logic tells here that the current task is not ready
  // to be completed and I would like to postpone it for the next iteration
  // It is possible to do that?

  // complete with update variables
  return {
    variables: {
      numberVar: newNumber
    }
  };
});

Thanks,
Ionut

Fetch all context variables by default

The default behavior of Camunda is to return all variables from the context when calling fetchAndLock unless you specifically ask for a subset of them:

variables A JSON array of String values that represent variable names. For each result task belonging to this topic, the given variables are returned as well if they are accessible from the external task's execution. If not provided - all variables will be fetched.

https://docs.camunda.org/manual/7.6/reference/rest/external-task/fetch/

With the current implementation in this package you have to explicit list the variables that you want included when registering the task worker. If no variables are listed, no context variables are returned. This makes it impossible to get all of the context variables without explicitly listing them all yet it is unlikely that a task will know the name of every single variable that exists in the process instance context.

start-workers will error in a Windows environment

Minor issue for Windows users...

When trying to start the example workers in a Windows environment the syntax in example/package.json DEBUG=orderProcess:*,worker,worker:*
will cause Node to error. The fix it to remove this from the package.json and set it in the shell.

For Windows PowerShell it would be:
$Env:DEBUG="orderProcess:*,worker,worker:*"

Thanks!
Aaron

Camunda via docker

"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."

I did that but is seems there is not engine-rest available...

boolean values being treated as strings

I've was trying to use a boolean value in the variables for the complete task method and it was being turned into a json string. I'm not sure if there is another way that to work with booleans that wouldn't require a change, but I added two lines of code to workers.js to handle the case where the type is boolean.
this is what I have now for the last if statement of the getSerializedType method:

if (typeof value === 'number') {
type = 'Double';
} else if(typeof value === 'boolean') {
type = 'Boolean';
}else{
type = 'String';
}

Dont' block polling on long-running tasks

Right now we block polling on long running tasks. This change (introduced with 2.0.0) should probably be reverted, as it long running in Node does not necessarily mean busy / overloaded.

Instead, we should continue polling and accept tasks. If users would like to put constraints onto how many tasks the workers instance accepts they could provide an additional component that tracks running tasks and updates pollingInterval accordingly.

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.