You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clarification on how to handle multiple-instance workflows when we are designing HttpEndPoints.
Enhancement Overview
I've created a workflow when I had some HttpEndpoints to get user approval on the other existing system which uses Elsa as Workflow engine.
I have following workflow:
public class SpecialWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
var queryStringsVariable = builder.WithVariable<IDictionary<string, object>>();
var messageVariable = builder.WithVariable<string>();
builder.Root = new Sequence
{
Activities =
{
new HttpEndpoint
{
SupportedMethods = new Input<ICollection<string>>(["POST"]),
Path = new("/SpecialCaseFlow"),
CanStartWorkflow = true,
QueryStringData = new(queryStringsVariable),
},
new WriteHttpResponse
{
Content = new(context => context.GetWorkflowExecutionContext().Id),
StatusCode = new Input<HttpStatusCode>(HttpStatusCode.OK),
},
new SendHttpRequest
{
Url = new Input<Uri?>(new Uri("https://localhost:7186/AddToSysAdminCartable")),
Method = new Input<string>("POST"),
},
new HttpEndpoint
{
SupportedMethods = new Input<ICollection<string>>(["POST"]),
Path = new("/{workflowInstanceId}/AssignManager"),
},
new SendHttpRequest
{
Url = new Input<Uri?>(new Uri("https://localhost:7186/AddToManagerCartable")),
Method = new Input<string>("POST"),
},
new HttpEndpoint
{
SupportedMethods = new Input<ICollection<string>>(["POST"]),
Path = new("/{workflowInstanceId}/AssignExpert"),
},
new SendHttpRequest
{
Url = new Input<Uri?>(new Uri("https://localhost:7186/AssingToExperts")),
Method = new Input<string>("POST"),
},
new End()
{
}
}
};
}
}
The problem is that Elsa is unable to find the exact WorkflowInstance using the route parameter that I've provided. It's so bad. I've read the main source code and I didn't find a clue about setting a tricky header or payload to tell Elsa "Bro I'm working with instance # 12" don't get confused 😁.
There must be a way of doing it.
Proposed Enhancement
Add some conventional Route or Header to tell clients that you are able to send your workflow instanceId using this conventionally accepted way.
Use Cases
Suppose that I have multiple instance of a workflow which Aimed to handle document approval process. I've over 100 agents that are handling this document approval. All of them has been already started a new instance of my SpecialFlow they needed to be able Approved message using HttpEndPoints to Elsa and continue the workflow.
Alternative solution
I already resolved this damn issue with following code:
public class SpecialWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
var queryStringsVariable = builder.WithVariable<IDictionary<string, object>>();
var messageVariable = builder.WithVariable<string>();
var uniqueId = Guid.New();
builder.Root = new Sequence
{
Activities =
{
new HttpEndpoint
{
SupportedMethods = new Input<ICollection<string>>(["POST"]),
Path = new("/SpecialCaseFlow"),
CanStartWorkflow = true,
QueryStringData = new(queryStringsVariable),
},
new WriteHttpResponse
{
Content = new(context => context.GetWorkflowExecutionContext().Id),
StatusCode = new Input<HttpStatusCode>(HttpStatusCode.OK),
},
new SendHttpRequest
{
Url = new Input<Uri?>(new Uri("https://localhost:7186/AddToSysAdminCartable")),
Method = new Input<string>("POST"),
},
new HttpEndpoint
{
SupportedMethods = new Input<ICollection<string>>(["POST"]),
Path = new($"/{uniqueId}/AssignManager"), // This no longer meant to be a route parameter.
},
new SendHttpRequest
{
Url = new Input<Uri?>(new Uri("https://localhost:7186/AddToManagerCartable")),
Method = new Input<string>("POST"),
},
new HttpEndpoint
{
SupportedMethods = new Input<ICollection<string>>(["POST"]),
Path = new($"/{uniqueId}/AssignExpert"), // This no longer meant to be a route parameter.
},
new SendHttpRequest
{
Url = new Input<Uri?>(new Uri("https://localhost:7186/AssingToExperts")),
Method = new Input<string>("POST"),
},
new End()
{
}
}
};
}
}
The text was updated successfully, but these errors were encountered:
Enhancement Request
Clarification on how to handle multiple-instance workflows when we are designing HttpEndPoints.
Enhancement Overview
I've created a workflow when I had some HttpEndpoints to get user approval on the other existing system which uses Elsa as Workflow engine.
I have following workflow:
The problem is that Elsa is unable to find the exact WorkflowInstance using the route parameter that I've provided. It's so bad. I've read the main source code and I didn't find a clue about setting a tricky header or payload to tell Elsa "Bro I'm working with instance # 12" don't get confused 😁.
There must be a way of doing it.
Proposed Enhancement
Add some conventional
Route
orHeader
to tell clients that you are able to send your workflow instanceId using this conventionally accepted way.Use Cases
Suppose that I have multiple instance of a workflow which Aimed to handle document approval process. I've over 100 agents that are handling this document approval. All of them has been already started a new instance of my
SpecialFlow
they needed to be ableApproved
message usingHttpEndPoints
toElsa
and continue the workflow.Alternative solution
I already resolved this damn issue with following code:
The text was updated successfully, but these errors were encountered: