FetchAndLock long poll feature

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.

Please find the attached diagram
parallelevent.bpmn (5.9 KB)

try to add the setting as part of the config that might do the trick

const config = { baseUrl: "http://localhost:8080/engine-rest", use: logger, asyncResponseTimeout: 90000 };

Thanks Niall for your quick response. The above setting worked for node.js script. We will try similar change in go client as well and see if it works.
This client setting will set for all topics right? if we want to set separate timeout for separate topics how to achieve that?

One other note your videos are excellent and quite helpful in understanding Camunda.

Hi ganga,

Indeed, this will be the setting used for all subscriptions to that client object.
I think if you want to run a topic using different settings for polling, you should just create a new client object.

I’m very happy to hear you find the videos useful. :slight_smile:

-Niall