惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
SecWiki News
SecWiki News
Project Zero
Project Zero
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Scott Helme
Scott Helme
A
Arctic Wolf
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
The Hacker News
The Hacker News
T
Tenable Blog
雷峰网
雷峰网
有赞技术团队
有赞技术团队
V
V2EX
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
T
Threatpost
AWS News Blog
AWS News Blog
L
LINUX DO - 热门话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
SegmentFault 最新的问题
月光博客
月光博客
Spread Privacy
Spread Privacy
S
Secure Thoughts
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
The Last Watchdog
The Last Watchdog
Y
Y Combinator Blog
I
Intezer
博客园 - 【当耐特】
B
Blog RSS Feed
Attack and Defense Labs
Attack and Defense Labs
I
InfoQ
博客园 - 叶小钗
Cyberwarzone
Cyberwarzone
V2EX - 技术
V2EX - 技术
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
H
Help Net Security
C
CERT Recently Published Vulnerability Notes

博客园 - Gary Zhang

Human-in-the-Loop (HITL) 设计文档-学习笔记 MiniMind 从零训练 LLM — 详细学习笔记 C端产品的三个关键词和B端产品的一个关键词 人工智能相关概念 经济活动原理推导 使用Matlab对账期客户订单的逾期率进行预测 BizTalk RosettaNet 解决方案 - Gary 存储HTTP请求Body部分到文件中 BizTalk Visual Studio 各版本自动部署GAC命令 RosettaNet PIP 清单 BizTalk RosettaNet解决方案与项目调研 ChatGPT可能的影响与机会 使用Google Bigquery快速用SQL查询Excel数据 Azure logic App 构建低成本EDI解决方案(英文) 从 BizTalk 跟踪数据库中清除数据 自助批量下载Confluence文档内容 Azure 升级订阅服务及服务区别 MIME 消息 BizTalk性能优化配置(建议) Azure Logic APP 与 EDIFACT/X12/RosettaNet/AS2解决方案概述 BizTalk 安装管理 API
Elsa 工作流引擎 Hello World
Gary Zhang · 2021-08-15 · via 博客园 - Gary Zhang

Elsa 简介

Elsa 是一个基于MIT协议的.Net的开源工作流引擎,也就是你可以基于它修改源码及进行商业化。与其他工作流产品的区别是首先它可以很轻量级的嵌入到你的应用里,为你的应用提供流程化的能力; 其次它有设计器、API可以可视化的进行流程设计; 再次,它提供性能或功能的扩展能力,扩展性强。

配置Elsa工作流引擎

简单配置Elsa 的Hello World应用程序使用Http请求作为触发条件和Http Response作为输出。

  1. 创建一个项目 dotnet new web -n "ElsaQuickstarts.Server.DashboardAndServer"
  2. 进入该项目目录
    cd ElsaQuickstarts.Server.DashboardAndServer

  3. 添加项目包引用
    dotnet add package Elsa
    dotnet add package Elsa.Activities.Http
    dotnet add package Elsa.Activities.Temporal.Quartz
    dotnet add package Elsa.Persistence.EntityFramework.Sqlite
    dotnet add package Elsa.Server.Api
    dotnet add package Elsa.Designer.Components.Web

  4. 使用Visual Studio修改Setup文件,使用如下内容替换原有内容。
    using Elsa;
    using Elsa.Persistence.EntityFramework.Core.Extensions;
    using Elsa.Persistence.EntityFramework.Sqlite;
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Hosting;
    namespace ElsaQuickstarts.Server.DashboardAndServer
    {
    public class Startup
    {
    public Startup(IWebHostEnvironment environment, IConfiguration configuration)
    {
    Environment = environment;
    Configuration = configuration;
    }
    private IWebHostEnvironment Environment { get; }
    private IConfiguration Configuration { get; }
    public void ConfigureServices(IServiceCollection services)
    {
    var elsaSection = Configuration.GetSection("Elsa");
    // Elsa services.
    services
    .AddElsa(elsa => elsa
    .UseEntityFrameworkPersistence(ef => ef.UseSqlite())
    .AddConsoleActivities()
    .AddHttpActivities(elsaSection.GetSection("Server").Bind)
    .AddQuartzTemporalActivities()
    .AddWorkflowsFrom<Startup>()
    );
    // Elsa API endpoints.
    services.AddElsaApiEndpoints();
    // For Dashboard.
    services.AddRazorPages();
    }
    public void Configure(IApplicationBuilder app)
    {
    if (Environment.IsDevelopment())
    {
    app.UseDeveloperExceptionPage();
    }
    app
    .UseStaticFiles() // For Dashboard.
    .UseHttpActivities()
    .UseRouting()
    .UseEndpoints(endpoints =>
    {
    // Elsa API Endpoints are implemented as regular ASP.NET Core API controllers.
    endpoints.MapControllers();
    // For Dashboard.
    endpoints.MapFallbackToPage("/_Host");
    });
    }
    }
    }

  5. 创建Pages文件夹,并建立_Host.cshtml文件,使用如下内容替换原文件。
    @page "/"
    @{
    var serverUrl = $"{Request.Scheme}://{Request.Host}";
    }
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Elsa Workflows</title>
    <link rel="icon" type="image/png" sizes="32x32" href="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/assets/images/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/assets/images/favicon-16x16.png">
    <link rel="stylesheet" href="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/assets/fonts/inter/inter.css">
    <link rel="stylesheet" href="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/elsa-workflows-studio.css">
    <script src="/_content/Elsa.Designer.Components.Web/monaco-editor/min/vs/loader.js"></script>
    <script type="module" src="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/elsa-workflows-studio.esm.js"></script>
    </head>
    <body>
    <elsa-studio-root server-url="@serverUrl" monaco-lib-path="_content/Elsa.Designer.Components.Web/monaco-editor/min">
    <elsa-studio-dashboard></elsa-studio-dashboard>
    </elsa-studio-root>
    </body>
    </html>

  6. 项目解决方案如下图

  7. 在Visual Studio中启动该服务

创建和测试Hello World流程

  1. 启动成功之后在流程器中输入https://localhost:5001, 如果是http访问,地址是http://localhost:5000 .

  2. 在流程定义(Workflow Definitions)中新建一个流程,这里借用Elsa官网的Gif图片来说明步骤。
    quickstarts-aspnetcore-server-dashboard-and-api-endpoints-animation-1

  3. 创建好流程之后就可以在浏览器中输入地址进行测试。

初步性能测试

使用Apache并发100个请求1000次,在完全默认的情况下得到如下结果。

可能是采用SQLLite作为持久化性能受到影响。暂时先不做评论。

参考资料

ASP.NET Core Server with Elsa Dashboard + Elsa Server API Endpoints