How to force an instance to be written to history immediately

Hi.
I wrote an process (simple for example). Camonda 7.15.0 spring boot / kotlin / postgress / history level = FULL

Process look like
start → service task (java class) → user task → end

In kotlin class i try to get processInstance from historyService

var historyService = execution?.processEngineServices?.historyService
context.initiator = historyService?.createHistoricProcessInstanceQuery()
?.processInstanceId(execution?.processInstanceId)
?.singleResult()?.startUserId

But at this moment instance not defined in historyList (and in postgres table also)
Also i try to get all instances and chek entire list.

This instance appears in the history service (and in the postgre table) only when it comes to a user task.
How can i force camunda to write instance every bpmn task/service stage?

Temporary a solve it by adding timer after start event (1 second).
I think instance stored at process “stop” stages (user task/external service/timer/messages etc.)
Where can i find desccriptions or complitely list of this stages?

@ivannoff You can configure save points to the service task types to write into database. It is very easy to enforce engine to write the data in db by configuring either of the below properties based on the requirement.

camunda:asyncBefore="true"

or

camunda:asyncAfter="true"

Process will start asynchronously:

Savepoint for service task:

2 Likes

@aravindhrs
thanks, that’s what i need