Let's have a workflow consisted of Receive activity followed by Delay activity.
The Receive activity has CanCreateInstance = true
and the query (message) correlation is also provided.
The workflow is hosted in workflow service
and is persisted into the database immediately on idle.
WorkflowService service = new WorkflowService
{
Name = "MyWorkflow",
Body = new MyWorkflow(),
Endpoints =
{
new Endpoint
{
ServiceContractName = "IMyWorkflow",
AddressUri = new Uri("http://localhost:1234/MyWorkflow"),
Binding = new BasicHttpBinding()
}
}
};
WorkflowServiceHost host = new WorkflowServiceHost(service);
string conn = "Data Source=...;Initial Catalog=...";
host.DurableInstancingOptions.InstanceStore = new SqlWorkflowInstanceStore(conn);
host.Open();
Now I send the message to the workflow and the runtime creates the first workflow instance. The correlation key is included in the message, of course. The workflow continues with Delay activity and is saved to the database and unloaded.
Let's assume the delay is long enough and I'll send next message with exactly the same correlation key. What happens? Both workflows are never woke up from the delay and never finished.
What do I wrong? Why workflow runtime doesn't protect me against this? Is there any way how to rescue both workflow instances?
Thanks for help!