workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

Waiting for an event in a while loop

Open paxhujing opened this issue 1 year ago • 2 comments

When you wait for an event in a while loop, you expect execution to continue each time the event is received and then continue waiting.

image

Why is context.ExecutionPointer.EventName null when CustomMessage.Run() executes, rather than the event name? context.ExecutionPointer.EventPublished Why is it false? Why don't loops wait?

image

paxhujing avatar Oct 11 '24 10:10 paxhujing

I have the same problem. Upon reviewing the data superficially, the event is not marked as consumed in the events table. It is possible that this is triggering the WaitFor repeatedly. In my case, I am using SQL Server.

Image

I don’t know if you resolved the issue, but I hope I can contribute to solving this problem.

egyware avatar Jan 21 '25 15:01 egyware

In the file WorkflowConsumer.cs, for some reason, after the event is successfully consumed and, in this case, the WaitFor is unlocked, the IsProcessed property is updated to True.

Then, for reasons I have yet to discover, the MarkEventUnprocessed function updates the IsProcessed property back to False. This causes the event to be re-enqueued and the WaitFor step in the workflow to be unlocked again.

I have been investigating this issue, but I still haven't identified the root cause of why MarkEventUnprocessed is being triggered.

egyware avatar Jan 21 '25 18:01 egyware