Hi,
I am using the camunda 7.9 version. I am trying to use long poll feature which is needed in my project.
I have created a sample bpmn file (attached) and the node.js client. I see that even after setting the
asyncResponseTimeout to 50000 msec (50 sec) the server returns the response immediately and the client
does not wait on the poll event. I am using camunda-external-task-client-js client. I have also tried on
the go client as well which also returns immediately without waiting on the poll.
Please help me how to make this long poll feature work.
Here is my node.js client code.
const {
Client,
logger,
Variables,
File
} = 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);
const options = {
asyncResponseTimeout: 50000
};
// susbscribe to the topic: ‘FightTribe’
client.subscribe(“FightTribe”, options, async function({ task, taskService }) {
// Put your business logic
// complete the task
const defeated = new Variables();
defeated.set(“status”, “defeated”);
const success = new Variables();
success.set( “status”, “victory”);
const randvar = Math.random();
console.log(randvar);
if (randvar > 0.9) {
console.log(‘battle lost’);
await taskService.complete(task, null, defeated);
}
else {
console.log(‘battle won’);
await taskService.complete(task, null, success);
}
});
The output is :
polling
✓ polled 0 tasks
polling
✓ polled 0 tasks
polling
✓ polled 0 tasks
polling
✓ polled 0 tasks
polling
✓ polled 0 tasks
There is no time lag between events.