Job worker

Hi Everyone,

I have one jobworker configured in java side and trying update the process variable after completion with the help of below code. And code got executed without any issue but I am unable to see these variables in operate.

@JobWorker(type = WorkerName.LOAD_URLS, fetchAllVariables = true)
	public void connectorURLs(final JobClient jobClient, final ActivatedJob activatedJob) {
		log.info("Worker:{} has been started.",WorkerName.LOAD_URLS);
		
		Map<String, Object> variables = activatedJob.getVariablesAsMap();
		log.info("available variables:{}",variables.toString());
		
		variables.put(CONNECTOR_URLS, CamundaServiceApp.connectorUrls);
		variables.put(HttpHeaders.AUTHORIZATION.toLowerCase(), getJWTToken());
        log.info("New variables:{}",variables);
 
		zeebeClient.newCompleteCommand(activatedJob).variables(variables)
				.send();
	}

Screenshot of BPMN process from operate where we can see no variables after execution.

TIA.

Hello @yadav1990 ,

have you put input/output parameters on the first step?

Jonathan

No, I have not added input/output and why do we need to add? As we are passing as process variable and it should be available right?

You may be looking at Operate wrong. I know that it doesn’t work the way I think it should in viewing variables, but I can never remember exactly how.

Put another service task in there - after your existing one - and in the handler log out the variable payload. From your code, it looks like it should be working.

In Operate, click around: on the element, on the canvas.

yes, I have tried by adding userTask but didn’t worked.

Hello @yadav1990 ,

can you see any variables in any scope of your process instance?
Scopes are the tasks of your process model that are shown in the instance history.

Jonathan

No. I can’t see the variable in any scope.

I think the suggestion was to leverage the code you’ve already written…
If you duplicate your code, and put a second service worker after the first one, your logs should show the variables that the instance has…

@JobWorker(type = "VERIFY_VARS", fetchAllVariables = true)
	public void connectorURLs(final JobClient jobClient, final ActivatedJob activatedJob) {
		log.info("Worker:VERIFY_VARS has been started.");
		
		Map<String, Object> variables = activatedJob.getVariablesAsMap();
		log.info("available variables:{}",variables.toString());
		
		zeebeClient.newCompleteCommand(activatedJob)
				.send();
	}

rather than trying to use a UserTask.

1 Like