Hello,
i created a External Task Skript in Javascript.
My Problem is that when i start the skript only detects a new task every ~3 Minutes.
How i can change it to 10 Secounds?
const { Client, logger } = require("camunda-external-task-client-js");
const { Variables } = 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("countMails", async function({ task, taskService }) {
// Put your business logic
});
Hello @0x1234567890 ,
when creating the new client, there are multiple options to configure the polling of the client.
Here is the reference: camunda-external-task-client-js/Client.md at master · camunda/camunda-external-task-client-js · GitHub
Here, you should look the asyncResponseTimeout as well as the interval.
For a basic understanding, here is the entry from our docs: External Tasks | docs.camunda.org
Hope this helps
Jonathan
2 Likes
@jonathan.lukas jonathan.lukas Hello i use:
const config = { baseUrl: "http://localhost:8080/engine-rest", interval: 1, autoPoll: true, maxParallelExecutions: 10, use: logger };
But it still take more than 3 Minutes.
Why?
Here is optimized config for fast (20ms) reaction for Nodejs client
// for fast parallel processing it is critical to reduse polling internal to low value
// create a Client instance with custom configuration
const config = { baseUrl: url, workerId: workerId, use: logger.level(loglevel), asyncResponseTimeout: longPolling, lockDuration: lockDuration,
maxTasks: maxTasks, interval: 5, autoPoll: false, interceptors: [basicAuthentication /*, sslValidation */] };
const client = new Client(config);
also you have to change engine parameter:
<job-executor>
<job-acquisition name="default">
<properties>
<property name="maxJobsPerAcquisition">50</property>
<property name="waitTimeInMillis">5</property>
<property name="maxWait">50</property>
<property name="lockTimeInMillis">300000</property>
<property name="backoffTimeInMillis">30</property>
<property name="maxBackoff">150</property>
</properties>
</job-acquisition>
<properties>
<property name="queueSize">100</property>
<property name="maxPoolSize">20</property>
</properties>
</job-executor>
1 Like
What are the values from: asyncResponseTimeout, lockDuration & maxTasks?
i never heared abaout the engine parameter. Are this a Setting for each BPMN or the hole Server?
Wehre i can find this configuration file?
const longPolling = process.env.LongPolling || 60000; // 60 seconds
const lockDuration = process.env.lockDuration || 50000; // 50 seconds
const loglevel = process.env.LogLevel || ‘INFO’;
const maxTasks = process.env.JobsToActivate || 25; // 10-200 ordinary
const workerId = process.env.workerId || ‘some-random-id’; // Unique worker id for every Worker
job executor setup in: bpm-platform.xml in /camunda/conf/ if docker used
1 Like
I have implement it. But it not worked for me.
It everytime stuck on a Service Task for 1-2 Minutes.
update: It suck forever. More than 30 minutes with your configuration.
The listener is subscrubed and did not get any error message:
maybe i used
auto poll = false and then client.start
check full example at:
const { Client, logger, BasicAuthInterceptor } = require('camunda-external-task-client-js');
// const fs = require('fs');
const { router } = require ('./js/router.js');
const { Redis } = require ('./js/redis.js');
// configuration for the Camunda Client:
// - 'baseUrl': url to the Process Engine
// - 'logger': utility to automatically log important events
// - 'asyncResponseTimeout': long polling timeout (then a new request will be issued)
// - 'maxTasks': The maximum number of tasks to fetch from Camunda in batch
// - 'maxParallelExecutions': The maximum number of tasks to be worked on simultaneously
// Number of async execution threads = maxTasks if maxParallelExcecutions is not set
// Else Number of async threads = min (MaxTasks,maxParallelExcecutions)
const url = process.env.CamundaUrl || 'http://camunda:8080/engine-rest';
const RedisUrls = process.env.RedisUrls || 'redis:6379';
const longPolling = process.env.LongPolling || 60000;
const tasktype = process.env.TaskType || 'service-task';
const loglevel = process.env.LogLevel || 'INFO';
This file has been truncated. show original
1 Like