elsa-workflows / elsa-workflows/elsa-core

Unexpected behavior when using Elsa.AzureServiceBus.MessageReceived in a loop

Open
#4,942 2 comments 0 reactions 1 assignee Claimed by @jdevillard View on GitHub
bug triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

I've found an unexpected behavior of a workflow when there's a loop that contains a MessageReceived activity.

The workflow is a simple for loop with the MessageReceived activity followed by the decision activity which checks the message content and decides wether to break the loop. See [workflow-3-1.json](https://github.com/elsa-workflows/elsa-core/files/14280183/workflow-3-1.json).

After recieving the first message the next iterations are not waiting for the next message but reusing the same message that came once. This causes the cycle completes in a blink ignoring the following messages and breaking the logic.

After some debugging I've found that it might be caused by the WorkflowInbox. After submitting a message once it dispatches it again and again.

Is this a desired behavior? How can I work around this? I tried to create a cusom activity similar to MessageReceived and use `workflowRuntime.DispatchAsync()` in the queue message consumer but it leads to the lost message situations when a message comes before the bookmark is stored.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.