Have a JavaDelegate that starts another process instance. When the instantiation API invocation returns, the process instance has not yet advanced to the first wait state, but to the first asyncCapable atomic operation. The remaining steps are completed later in the same transaction after the JavaDelegate has finished (or never, if the executions are ended in between, for example due to a terminate end event).
Test case: https://github.com/camunda/camunda-bpm-platform/commit/cf35b5ca226a3b7876480004475317a9e80210a8
Solution idea:
Move the list of queued AtomicOperations (queuedOperations) from CommandContext to CommandInvocationContext such that it exists once per command.