nikku / camunda-worker-node Goto Github PK
View Code? Open in Web Editor NEWImplement your external task workers for Camunda in NodeJS.
Home Page: https://www.npmjs.com/package/camunda-worker-node
License: MIT License
Implement your external task workers for Camunda in NodeJS.
Home Page: https://www.npmjs.com/package/camunda-worker-node
License: MIT License
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?
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
| };
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?
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
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.
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
"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...
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';
}
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.
The callbac url for failed tasks is incorrect, which is preventing failed tasks being marked as such in Camunda.
In lib/engine/api.js
'/external-task/' + taskId + '/failed'
Should be
'/external-task/' + taskId + '/failure'
See https://docs.camunda.org/manual/7.6/reference/rest/external-task/post-failure/#method
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.