[New Activity] Command Executer #6322
Open
+310
−42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Simple lightweight Activity Scans your Assembly and register your custom-made commands
(The ones that inherits the class
ElsaWorkFlowCommand
)Then execute them in Elsa Context.
But what about the Command payload?
It can be sent in the form of
Json
and the command will automaticallymap the json to the command object. Yes ! using reflection.
Example use case:
after an endpoint got hit , i need to save the data at the database or i need to send an OTP , of course currently Elsa support using webhooks and submit the body to an Api, But this one saves you an extra layer of work which is the REST Api .......
you can use it as follows :
But how can i send paylaod of the command ?
simply like this : of course you can use Elsa variables inputs and so on to build up you payload, and it can take a very complex objects
when Elsa executes this activity
it runs the handler , in case of exception the workflow become faulted with the exception details for revive.
Getting started with this activity:
at the
Program.cs
and then you have to register your handles to Elsa Mediator like this
builder.Services.AddCommandHandlersFrom<YoutCommandsAssembly>();
Example of a command and a handler :
then enjoy.
This change is