Dear Camunda Community,
I’m trying to implement an external NodeJS job worker using zeebe-client-node-js. Everything seems to work and I am having no errors in my code but somehow the ‘orderStatus’ variable is not updating when a job is completed and I log process outcome. The ‘orderStatus’ variable is updated into the database but the ‘orderStatus’ variable inside the process outcome is not updating. Any ideas what I’m doing wrong?
The variable is updated inside my database:
The variable is not updated in the Process outcome:
Here is the code:
const customerOrderStatusRejected = zbc.createWorker({
taskType: 'customerOrderStatusRejected',
taskHandler: handler,
debug: true,
loglevel: 'INFO',
onReady: () => customerOrderStatusRejected.log('Job worker started successfully!')
});
function handler(job) {
customerOrderStatusRejected.log('Task variables', job.variables)
try {
const updatedProperty = parseInt(job.variables.updatedProperty)
var connection = mysql.createConnection({
host: process.env.MYSQL_HOST_NAME,
user: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD,
database: process.env.MYSQL_DATABASE,
port: process.env.MYSQL_HOST_PORT,
});
connection.connect();
connection.query('UPDATE `customer_order` SET `orderStatus` = "ORDER_REJECTED" WHERE `customer_order`.`id` = ' + updatedProperty + ';',
async function (error, results, fields) {
if (error) throw error;
console.log('Results: ', JSON.stringify(results));
});
connection.end();
} catch (error) {
console.log(error)
}
const updateToBrokerVariables = {
updatedProperty: 'newValue',
}
return job.complete(updateToBrokerVariables)
}
module.exports = customerOrderStatusRejected;
Any help shall be highly appreciated. Thank you in advance!
Kind regards,
Rahib B.