Get Execution variables of a DeadLetter Job

Hello,

We have a BPMN that includes an asynchronous ServiceTask (expression type).
When the Service Task fails (after the retries), the job goes to the Deadletter and we can see the exception stack trace (“error while evaluation expression: ${myService.doSomething(execution.getVariables)}”).

¿Is there any way to get the execution variables used in the ServiceTask expression call?

Thanks in advance

Hello,

We have found a way to do this:

Job job = managementService.createDeadLetterJobQuery().jobId(id).singleResult();
	
if (job != null) {
	
	Execution jobExecution = runtimeService.createExecutionQuery()
		.executionId(job.getExecutionId())
		.processInstanceId(job.getProcessInstanceId())
		.list().stream()
			//we filter the list because we can't use activityId filter in query because that filter adds the execution alive condition)
			.filter( execution -> job.getElementId().equals(execution.getActivityId()) )
			.findFirst()
			.orElse(null);
	
	if (jobExecution != null) {
		//Lazy loading of variables. We need executing inside a CommandContext
		Map<String, Object> data = managementService.executeCommand(new Command<Map<String,Object>>() {
	
			@Override
			public Map<String,Object> execute(CommandContext commandContext) {
				
				return ((ExecutionEntity)jobExecution).getVariables();
	
			}
		});
	
	}
}

We don’t know if this is the best solution, but it works.

Thanks