I set the businessKey in a service task right after the message start event.
However, when I use the historyService to get the historyProcessInstance , I am not getting any result.
If history works (turned on, on the right history level, synchronous history…), it should work. If not could you try to reproduce the issue in the jUnit test?
That is not a bug @martin.grofcik.
If CmmnRuntimeService#updateBusinessKey(String, String) is used, e.g. cmmnRuntimeService.updateBusinessKey(caseInstance.getId(), 'my key'), then everything should work correctly. Irregardless whether the async history is used or not.
@mykeul if you use runtimeService.updateBusinessKey(execution.getProcessInstanceId(), "myBusinessKey")); then everything should be fine. The only thing is that if you try to query by the business key within the same transaction / command context execution then it won’t work.
Ideally you could provide a test case that we can look into.
It works now. It was a problem in my code.
I first thought that because I set the key after the wait state, it is not persisted yet and I cannot retrieve it from history service.
I understand that from the same transaction, it won’t work.
performs businessKey update in the history too (version 6.6.1). Version 6.7.0 org.flowable.cmmn.engine.impl.history.DefaultCmmnHistoryManager#recordCaseInstanceStart is called before case instance business key initialization.
You are right, I can use cmmnRuntimeService.setBusinessKey(...) instead. I do not need to migrate definitions to higher versions.