Skip to content
Discussion options

You must be logged in to vote

Hi @SamueleFurnari,

One easy way to see if there's already an active (non-completed, non-faulted) workflow is to use the IWorkflowInstanceStore and count the number of workflow instances for a given workflow definition ID and correlation ID, like this:

var workflowDefinitionId= "some workflow definition ID";
var correlationId = "some correlation ID";

// Setup query specification.
var specification = new WorkflowDefinitionIdSpecification(workflowDefinitionId).And(new WorkflowIsAlreadyExecutingSpecification()).WithCorrelationId(correlationId);

// Count matching results.
var workflowInstanceExists = await _workflowInstanceStore.CountAsync(specification) > 0;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SamueleFurnari
Comment options

Answer selected by SamueleFurnari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants