How to persist workflow state and resume particular activity from where it was Suspended #4928
Replies: 1 comment
-
To decide which persistence provider to use with ELSA Workflows, you should consider the specific needs of your application, such as performance requirements, existing infrastructure, developer expertise, and future scalability. Each persistence provider has its own set of pros and cons, and the best choice depends on the context of your application. Here are some general considerations for each:
To achieve persistence using MongoDB, you would configure ELSA to use the MongoDB provider. Here's an example of how you might configure it: services
.AddElsa(elsa => elsa
.UseMongoDbPersistence(options => options.ConnectionString = "your-mongodb-connection-string")
.AddConsoleActivities()
.AddHttpActivities()); To resume a particular activity from where it was suspended, ELSA uses bookmarks. When a workflow is suspended, ELSA creates a bookmark for the activity that caused the suspension. When the event that the bookmark corresponds to occurs, ELSA uses the bookmark to resume the workflow from the point of suspension. Here's a high-level example of how you might handle this: // Assuming you have a workflow instance that has been suspended
var workflowInstanceId = "your-workflow-instance-id";
var bookmarkName = "your-bookmark-name"; // The name of the bookmark to resume from
var bookmarkResult = await workflowRunner.RunWorkflowAsync(workflowInstanceId, bookmarkName); Please note that the actual implementation will depend on the specifics of your application and the events you're handling. For more detailed examples and documentation, you should refer to the official ELSA documentation and resources:
|
Beta Was this translation helpful? Give feedback.
-
As per ELSA workflow documentation , there are different ways to persist workflow's state like EF core, Mongo DB, YesSQL etc. When to use which and their cons and pros? Which is better way for real time application. how to achieve using Mongo DB? After maintaining state how to resume particular activity from where it was Suspended? Can someone please explain with example?
Beta Was this translation helpful? Give feedback.
All reactions