Business Key unavailable after process instance starts in custom history event handler

Hello,

I’m using a custom HistoryEventHandler to stream events out of Camunda. Part of this process is normalizing the records to have some common fields one of which is the business key. Only the HistoricProcessInstanceEventEntity history events contain the business key, which are process level events, (start, suspend, cancel, complete). The history events for other nodes in the process do not contain the business key and I am using the RuntimeService to lookup the ProcessInstance to fetch the business key. However, following a process start there are about 3 events and on each attempt to fetch the process instance the query returns no results. Subsequent events I am able to fetch the ProcessInstance with no trouble. It only returns no results following the process start. Below is a snippet I’m using to fetch the ProcessInstance.

ProcessInstance processInstance = ProcessEngines.getDefaultProcessEngine().getRuntimeService()
                .createProcessInstanceQuery()
                .processInstanceId(processInstanceId)
                .singleResult();

        return Optional.ofNullable(processInstance);

Any help or suggestions is much appreciated. I’m using the Spring Boot Starter running Camunda 7.10 enterprise edition.