Ejemplo n.º 1
0
        public async Task <IDeployResponse> Deploy(string modelFilename)
        {
            var filename   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory !, "Processes", modelFilename);
            var deployment = await _client.NewDeployCommand().AddResourceFile(filename).Send();

            return(deployment);
        }
Ejemplo n.º 2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            //deploy latest
            var deployResponse = await _client.NewDeployCommand().AddResourceFile(@"c:\Users\jany\Downloads\order.yaml").Send();

            _backgroundTask = Task.Run(BackgroundProceessing);
        }
Ejemplo n.º 3
0
        public async Task <bool> DeployFlow(string name, byte[] resourceBytes)
        {
            var result = await _client.NewDeployCommand()
                         .AddResourceBytes(resourceBytes, name)
                         .Send();

            return(result != null && result.Key >= 0);
        }
Ejemplo n.º 4
0
        public async Task Setup()
        {
            zeebeClient = await testHelper.SetupIntegrationTest();

            var deployResponse = await zeebeClient.NewDeployCommand()
                                 .AddResourceFile(DemoProcessPath)
                                 .Send();

            processDefinitionKey = deployResponse.Processes[0].ProcessDefinitionKey;
        }
Ejemplo n.º 5
0
        public async Task <IDeployResponse> Deploy(string modelFile)
        {
            var filename   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory !, "Resources", modelFile);
            var deployment = await _client.NewDeployCommand().AddResourceFile(filename).Send();

            var res = deployment.Workflows[0];

            _logger.LogInformation("Deployed BPMN Model: " + res?.BpmnProcessId +
                                   " v." + res?.Version);
            return(deployment);
        }
Ejemplo n.º 6
0
        public static async Task Main(string[] args)
        {
            // create zeebe client
            _client = ZeebeClient.NewZeebeClient(ZeebeUrl);
            // deploy
            var deployResponse = await _client.NewDeployCommand().AddResourceFile(DemoProcessPath).Send();

            // create workflow instance
            var workflowKey = deployResponse.Workflows[0].WorkflowKey;

            // 客户端生成多个流程数据
            await GenerateMultiFlowInstances(workflowKey);

            //await _client.NewSetVariablesCommand(workflowInstance.WorkflowInstanceKey).Variables("{\"func_instance\":\"collect money for your orders\"}").Local().Send();

            // open job worker
            using (var signal = new EventWaitHandle(false, EventResetMode.AutoReset))
            {
                _client.NewWorker()
                .JobType("collectmoney")
                .Handler(HandleJob)
                .MaxJobsActive(5)
                .Name("collectmoney")
                .AutoCompletion()
                .PollInterval(TimeSpan.FromSeconds(1))
                .Timeout(TimeSpan.FromSeconds(10))
                .Open();
                _client.NewWorker()
                .JobType("fetchitems")
                .Handler(HandleJob)
                .MaxJobsActive(5)
                .Name("fetchitems")
                .AutoCompletion()
                .PollInterval(TimeSpan.FromSeconds(1))
                .Timeout(TimeSpan.FromSeconds(10))
                .Open();
                _client.NewWorker()
                .JobType("shipparcel")
                .Handler(HandleJob)
                .MaxJobsActive(5)
                .Name("shipparcel")
                .AutoCompletion()
                .PollInterval(TimeSpan.FromSeconds(1))
                .Timeout(TimeSpan.FromSeconds(10))
                .Open();
                // blocks main thread, so that worker can run
                WaitHandle.WaitAll(new WaitHandle[]
                {
                    signal
                });
            }
        }
Ejemplo n.º 7
0
        public async Task ShouldCreateWorkflowInstance()
        {
            // given
            var deployResponse = await zeebeClient.NewDeployCommand()
                                 .AddResourceFile(DemoProcessPath)
                                 .Send();

            var workflowKey = deployResponse.Workflows[0].WorkflowKey;

            // when
            var workflowInstance = await zeebeClient
                                   .NewCreateWorkflowInstanceCommand()
                                   .WorkflowKey(workflowKey)
                                   .Variables(WorkflowInstanceVariables)
                                   .Send();

            // then
            Assert.AreEqual(workflowInstance.Version, 1);
            Assert.AreEqual(workflowKey, workflowInstance.WorkflowKey);
            Assert.AreEqual("demoProcess", workflowInstance.BpmnProcessId);
            Assert.Greater(workflowInstance.WorkflowInstanceKey, 1);
        }
        public async Task ShouldCreateProcessInstance()
        {
            // given
            var deployResponse = await zeebeClient.NewDeployCommand()
                                 .AddResourceFile(OneTaskProcessPath)
                                 .Send();

            var processDefinitionKey = deployResponse.Processes[0].ProcessDefinitionKey;

            // when
            var processInstance = await zeebeClient
                                  .NewCreateProcessInstanceCommand()
                                  .ProcessDefinitionKey(processDefinitionKey)
                                  .Variables(ProcessInstanceVariables)
                                  .Send();

            // then
            Assert.AreEqual(processInstance.Version, 1);
            Assert.AreEqual(processDefinitionKey, processInstance.ProcessDefinitionKey);
            Assert.AreEqual("oneTaskProcess", processInstance.BpmnProcessId);
            Assert.Greater(processInstance.ProcessInstanceKey, 1);
        }
Ejemplo n.º 9
0
        public async Task Send(dynamic variables)
        {
            // create zeebe client
            _client = ZeebeClient.NewZeebeClient(_zeebeUrl);
            // deploy
            var deployResponse = await _client.NewDeployCommand().AddResourceFile(_path).Send();

            // create workflow instance
            var workflowKey = deployResponse.Workflows[0].WorkflowKey;

            await _client
            .NewCreateWorkflowInstanceCommand()
            .WorkflowKey(workflowKey)
            .Variables(JsonConvert.SerializeObject(variables))
            .Send();
        }
Ejemplo n.º 10
0
        public async Task DeployProcessTest()
        {
            // given

            // when
            var deployResponse = await zeebeClient.NewDeployCommand()
                                 .AddResourceFile(DemoProcessPath)
                                 .Send();

            // then
            Assert.Greater(deployResponse.Key, 0);

            var deployedProcesses = deployResponse.Processes;

            Assert.AreEqual(1, deployedProcesses.Count);

            Assert.AreEqual(1, deployedProcesses[0].Version);
            Assert.Greater(deployedProcesses[0].ProcessDefinitionKey, 1);
            Assert.AreEqual("simpleProcess", deployedProcesses[0].BpmnProcessId);
            Assert.AreEqual(DemoProcessPath, deployedProcesses[0].ResourceName);
        }
Ejemplo n.º 11
0
        public async Task DeployWorkflowTest()
        {
            // given

            // when
            var deployResponse = await zeebeClient.NewDeployCommand()
                                 .AddResourceFile(DemoProcessPath)
                                 .Send();

            // then
            Assert.Greater(deployResponse.Key, 0);

            var deployedWorkflows = deployResponse.Workflows;

            Assert.AreEqual(1, deployedWorkflows.Count);

            Assert.AreEqual(1, deployedWorkflows[0].Version);
            Assert.Greater(deployedWorkflows[0].WorkflowKey, 1);
            Assert.AreEqual("demoProcess", deployedWorkflows[0].BpmnProcessId);
            Assert.AreEqual(DemoProcessPath, deployedWorkflows[0].ResourceName);
        }