Elsa work flow trigger and integration with exe

562 Views Asked by At

I want to build Elsa workflow for the below requirement:

  1. Can be trigger from database table trigger when new row inserted.
  2. Can execute exe file to get some information.
  3. To read data from the database.
1

There are 1 best solutions below

0
On

I agree with @fatihyildizhan and @vahidnaderi, but if I interpret the question as "How to do these 3 steps with Elsa from a high-level overview - can someone give me any pointers?" then I can answer as follows:

If all you really need are the 3 steps you mentioned, then don't use Elsa; it is overkill for what you want to do.

Here's why:

Although you can achieve all of this with Elsa, you can't do it with Elsa out of the box; you will have to write custom activities and support services to trigger your workflows, which is a little bit more work than simply doing your thing from your "row inserted" application handler.

If, on the other hand, you are planning on implementing multiple workflows that are potentially more complicated and perhaps even long-running, then it might be worthwhile to consider Elsa after all.

Doing this with Elsa requires you the following up-front work:

1. Trigger Workflow When New Row Inserted

To trigger a workflow when a new row is inserted, you need to implement a handler that responds to that event (this you would need to do regardless of whether you use Elsa or not).

Next, you need to implement a custom activity that represents the "row inserted" event as a trigger, e.g. called RowInserted. You can then use that activity as a starting point in any of your workflows or even as a resumption point (e.g. for workflows where you began some work that might insert some eventual addition of a database row, which is the event you want to handle), which would be triggered whenever a new row is inserted. You probably want to be able to configure for which database table to trigger this event, so you might add a TableName property to your activity.

Then, in order to make Elsa actually trigger workflows with your custom activity, you will need to do the following:

  1. Implement a bookmark model and provider for Elsa to index and invoke. E.g. NewRowBookmark : IBookmark with a single property called TableName. Bookmarks are Elsa's way of starting & resuming workflows.
  2. Update your "row inserted" handler described earlier to invoke IWorkflowLaunchpad.CollectAndDispatchWorkflowsAsync, passing in the appropriate bookmark/trigger model containing the table name into which the row was inserted, and provide the inserted row as input (assuming you want the workflow to do something with the inserted row).

2. Execute File

To execute a file, you need to create another custom activity that does this. You can make this activity as specific or generic as you need.

3. Read From Database

Same as with #2, you need to create another custom activity that reads from the database. You can make this activity as specific or generic as you need.

The above should give you a rough idea of the work involved to implement this with Elsa. And as mentioned earlier, this might be overkill if all you are looking to do is do the 3 steps mentioned.