microsoft / durabletask-java

Java SDK for Durable Functions and the Durable Task Framework
MIT License
13 stars 7 forks source link

Loop inside orchestration causing external events being ignored? #187

Closed kaibocai closed 7 months ago

kaibocai commented 7 months ago

Need to check if the same issue happens here as well. https://github.com/dapr/java-sdk/issues/967

kaibocai commented 7 months ago

This behavior is expected

Cause: https://github.com/microsoft/durabletask-java/blob/ad8c959b580a635da818b6f4c56731adce0a8ef3/client/src/main/java/com/microsoft/durabletask/TaskOrchestrationExecutor.java#L420C28-L420C48, each iteration there are two tasks created and we put them in our task queue, but eventually only one task will be consumed in one iteration, so in next iteration, the other event will consume the old task left in the queue causing the behavior that this event is ignored (anyway we already lose the reference to the old task). Because we are using the loop inside the workflow, the task queue is a singleton so old unconsumed tasks will pipe in that singleton queue causing this behavior.