Zeebe .Net Core 客户端(六)使用起始消息启动流程

一般情况下,流程的起始节点是None Event类型的,这种类型的流程需要显示创建流程,详见第二讲。如果需要使用消息启动流程,需要将起始节点设置为Message Start Event。我们看下面这个流程:


图片.png

这个流程中,请假人通过界面或者其它方式提交请假申请,这时还没有流程实例,当流程引擎接收到消息后,会创建一个流程实例,并继续执行流程。这部分代码是这样的:

using NLog.Extensions.Logging;
using System;
using System.Threading.Tasks;
using Zeebe.Client;

namespace SendApplyMessage
{
    class Program
    {
        private static readonly string ZeebeUrl = "127.0.0.1:26500";
        private static readonly string WorkflowInstanceVariables = "{\"ApplyId\":\"123\",\"Name\":\"张三\",\"Days\":3}";

        static async Task Main(string[] args)
        {
            // create zeebe client
            var client = ZeebeClient.Builder()
                .UseLoggerFactory(new NLogLoggerFactory())
                .UseGatewayAddress(ZeebeUrl)
                .UsePlainText()
                .Build();

            var resp = await client.NewPublishMessageCommand()
                   .MessageName("Message_Apply")
                   .CorrelationKey(string.Empty)
                   .Variables(WorkflowInstanceVariables)
                   .Send();
            Console.WriteLine(resp);
        }
    }
}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。