I’m not sure if this is a Process Engine or Modeler question, and I’ve read a few posts about this in the forum archives, but I’m struggling with multi-instance compensation. I have a the attached model, but I can’t seem to get the compensating task to fire.
TestMultiComp.bpmn (6.9 KB)
I’m running the following JavaScript external task processor:
const { Variables, Client, logger } = require('camunda-external-task-client-js');
const open = require('open');
const config = { baseUrl: 'http://localhost:8080/engine-rest', use: logger, asyncResponseTimeout: 10000 };
// create a Client instance with custom configuration
const client = new Client(config);
// subscribe to the topic: 'do-something-topic'
client.subscribe('do-something-topic', async function({ task, taskService }) {
// Get a process variable
const item = task.variables.get('item');
// set a local variable 'item'
const localVariables = new Variables();
localVariables.set("item", item);
console.log(`Do something with '${item}'...`);
if (item == 'three') {
// Raise Error
console.log(`Error '${item}'...`);
await taskService.handleBpmnError(task, "ERR_001", "Error Message");
} else {
// Complete the task
console.log(`Complete '${item}'...`);
await taskService.complete(task, null, localVariables);
}
});
// subscribe to the topic: 'compensate-topic'
client.subscribe('compensate-topic', async function({ task, taskService }) {
console.log(`Rollback...`);
const values = task.variables.getAll();
console.log(values);
// Complete the task
await taskService.complete(task);
});
The goal is to compensate any tasks that were started by the multi-instance subprocess.
Any help understanding how I should be modeling this or handling the compensation with external task would be would be appreciated.