In our application all service tasks are implemented as described here (https://github.com/camunda/camunda-bpm-examples/tree/master/servicetask/service-invocation-asynchronous). On execute method we send message to massage broker with the current executionId, and when we receive response we call runtime.signal with the same executionId.
The problem is, that some times remote service may send a response before process is flushed to database. So when the signal method is called camunda throws exception - no execution with this id.
So my question is how to send message after camunda saves the state of execution to the database.
For now I see only one solution: save message for remote service in some variable (thread local), create command interceptor and inside after next.execute(command) send this message to broker.