HistoryEventhandler: missing variables

We’re using Camunda 7.13.
We have a custom HistoryEventhandler (“implements HistoryEventHandler”) in which we do some additional handling whenever a process instance is started. We start the process like this:

final Map<String, Object> params = new HashMap<>();
params.put("foo", 1);
runtimeService.startProcessInstanceById(id, businessKey, params)

And then, the engine calls the handleEvent-method in the handler:

@Override
    public void handleEvent(final HistoryEvent historyEvent) {

Integer foo = (Integer) runtimeService.getVariable(historyEvent.getProcessInstanceId(), "foo");
}

Here, “foo” is null because there are no variables saved in the process instance (runtimeService.getVariables(historyEvent.getProcessInstanceId() returns an empty list). This worked flawlessly with 7.12 and earlier versions. It also seems not to happen all the time, but in 9 out of 10 cases.
Any suggestions?

Does your bpmn has an async start event? Try it like that. Maybe he doesn’t commit the transaction when you start the process but he triggers the listener.

Async start event or not does not seem to make a difference.

Hey @Matthias_Dietl,

I have the same issue.
I don’t get why on process instance event the variables are inaccessible but they are accessible on activity instance event.
Did you find any fix or any leads ?
Thanks

Hey @Ben_M,

I created a bugreport which is now treated as a feature request: https://jira.camunda.com/browse/CAM-13578

So far no workaround, we’re still on 7.12 because of this.

1 Like