美文网首页
Elsa Workflow

Elsa Workflow

作者: 寻找无名的特质 | 来源:发表于2022-08-06 07:02 被阅读0次

That's a great use case for Elsa and is something I am planning to create a sample application + guide for. So far, there are guides and samples about executing long-running "back-end" processes using Elsa, but there is now reason one couldn't also use it to implement application navigation logic such as wizards consisting of steps implemented as individual screens for example.

So that's your answer: yes, it is a relevant scenario. But it is unfortunate that there are no concrete samples to point you to at the moment.

Barring any samples, here's how it might work in a client application:

The client application has Elsa services configured.
Whether you decide to store workflow within the app (as code or JSON) or on a remote Elsa Server instance doesn't matter - once you have a workflow in memory, you can execute it.
Since your workflows will be driving UI, you have to think of how tightly-coupled the workflow will be with that UI. For example, a highly tight-coupled workflow might include activities that represent view (names) to present, including transition configuration if that is something to be configured, and outcomes based on what buttons were clicked. A highly loose-coupled workflow on the other hand might act more as a "conductor" or orchestrator of actions and events, where the workflow consists of nothing more than a bunch of primitives such as "SendCommand" and "Event Received", where a "SendCommand" simply raises some application event with a task name that your application then handles. The "Event Received" activity handles the other way around: your application fires instructions to Elsa, and Elsa drives the workflow. A task might be a "Navigate" instruction with the next view name provided as a parameter.
The "SendCommand" and "EventReceived" activities are very new and part of Elsa 2.1 preview packages. Right now they are directly coupled to webhook scenarios (where the commands are sent in the form of HTTP requests to an external application), but the goal is to have various strategies in place (HTTP out requests would just be one of them, another one might be a simple mediator pattern for in-process scenarios such as your client application one).

UPDATE
To retrieve workflows designed in the designer into your client app, you need to get the workflow definition via the following API endpoint:

http(s)://your-elsa-server/v1/workflow-definitions/{workflow-definition-id}/Published

What you'll get back is a JSON representing the workflow definition, which you can now deserialize using IContentSerializer.Deserialize<WorkflowDefinition>, which will give you a WorkflowDefinition. But to be able to actually run a workflow, you need a workflow blueprint. To turn the workflow definition into a blueprint, use `IWorkflowBlueprintMaterializer.CreateWorkflowBlueprintAsync(WorkflowDefinition).

Which will give you a blueprint that can then be executed using e.g. IStartsWorkflow.StartWorkflowAsync(IWorkflowBlueprint).

There are various other services that make it more convenient to construct and run workflows.

To make this as frictionless as possible for your client app, you could consider simply implementing IWorkflowProvider, of which we currently have 3 out of the box:

ProgrammaticWorkflowProvider: provides workflow blueprints based on the workflows coded with the fluent Workflow Builder API.
DatabaseWorkflowProvider: provides blueprints based on those stored in the database (JSON models stored by the designer).
StorageWorkflowProvider: provides blueprints based on JSON files stored on some hard drive or blob storage such as Azure Blob Storage.
What you might do, and in fact what I think we should provide out of the box now that you made me think of it, is create a fourth provider that uses the API endpoints to get workflows from.

Then your client app should not have to be bothered with invoking the Elsa API - the provider does it for you.

相关文章

  • Elsa Workflow

    That's a great use case for Elsa and is something I am pl...

  • Elsa Workflow概念

    工作流:一个工作流包括一系列步骤,称为活动(activity),这些活动彼此相连。一个工作流保持一组信息,比如哪个...

  • 创建Elsa Workflow Dashboard 和服务项目

    首先创建一个空的Web 项目:dotnet new web -n "ElsaQuickstarts.Server....

  • Workflow

    Workflow入门Workflow 教程(一)Workflow 教程(二)

  • Elsa

    可爱的Elsa 下午3:30,Elsa在酣睡中被爸爸的电话吵醒,非常不爽,我抱着哄睡着了,我的手也差不多力气耗尽了...

  • AWS SWF

    Concepts workflow. A workflow is a set of activities that...

  • 比特币地址查询

    利用Workflow一键查询比特币地址余额 说明:1.下载Workflow:https://workflow.is...

  • J2EE VS Spring website workflow

    J2EE website workflow Spring website workflow

  • 2020-11-10 Workflow can't be tri

    Q:Workflow 不能被启动A: 因为 Service Catalog Request workflow ...

  • 【iOS】效率提升工具--Workflow

    workflow是什么?干嘛用的? workflow是iOS上一款工具App,workflow本意是工作流,里面内...

网友评论

      本文标题:Elsa Workflow

      本文链接:https://www.haomeiwen.com/subject/adbqmrtx.html