Пример #1
0
        public ZeebeService(IConfiguration config, ILogger <ZeebeService> logger)
        {
            Configuration = config;
            var authServer   = Configuration["ZEEBE_AUTHORIZATION_SERVER_URL"];
            var clientId     = Configuration["ZEEBE_CLIENT_ID"];
            var clientSecret = Configuration["ZEEBE_CLIENT_SECRET"];
            var zeebeUrl     = Configuration["ZEEBE_ADDRESS"];

            char[] port =
            {
                '4', '3', ':'
            };
            var audience = zeebeUrl?.TrimEnd(port);

            _logger = logger;

            _client =
                ZeebeClient.Builder()
                .UseLoggerFactory(new NLogLoggerFactory())
                .UseGatewayAddress(zeebeUrl)
                .UseTransportEncryption()
                .UseAccessTokenSupplier(
                    CamundaCloudTokenProvider.Builder()
                    .UseAuthServer(authServer)
                    .UseClientId(clientId)
                    .UseClientSecret(clientSecret)
                    .UseAudience(audience)
                    .Build())
                .Build();
        }
        public ZeebeService(IEnvReader envReader, ILogger <ZeebeService> logger)
        {
            _logger = logger;
            var authServer   = envReader.GetStringValue("ZEEBE_AUTHORIZATION_SERVER_URL");
            var clientId     = envReader.GetStringValue("ZEEBE_CLIENT_ID");
            var clientSecret = envReader.GetStringValue("ZEEBE_CLIENT_SECRET");
            var zeebeUrl     = envReader.GetStringValue("ZEEBE_ADDRESS");

            char[] port =
            {
                '4', '3', ':'
            };
            var audience = zeebeUrl?.TrimEnd(port);

            _client =
                ZeebeClient.Builder()
                .UseGatewayAddress(zeebeUrl)
                .UseTransportEncryption()
                .UseAccessTokenSupplier(
                    CamundaCloudTokenProvider.Builder()
                    .UseAuthServer(authServer)
                    .UseClientId(clientId)
                    .UseClientSecret(clientSecret)
                    .UseAudience(audience)
                    .Build())
                .Build();
        }
Пример #3
0
 public void Stop()
 {
     client.Dispose();
     server.ShutdownAsync().Wait();
     testService = null;
     server      = null;
     client      = null;
 }
Пример #4
0
        public async Task TearDownIntegrationTest()
        {
            client.Dispose();
            client = null;
            await container.StopAsync();

            container = null;
        }
Пример #5
0
        public async Task Setup()
        {
            container = CreateZeebeContainer();
            await container.Start();

            client = CreateZeebeClient();

            await AwaitBrokerReadiness();
        }
Пример #6
0
        public async Task <IZeebeClient> SetupIntegrationTest()
        {
            container = CreateZeebeContainer();
            await container.StartAsync();

            client = CreateZeebeClient();
            await AwaitBrokerReadiness();

            return(client);
        }
Пример #7
0
        public async Task Setup()
        {
            zeebeClient = await testHelper.SetupIntegrationTest();

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

            processDefinitionKey = deployResponse.Processes[0].ProcessDefinitionKey;
        }
Пример #8
0
 public JobWorkerBuilder(IZeebeClient zeebeClient,
                         Gateway.GatewayClient gatewayClient,
                         ILoggerFactory loggerFactory = null)
 {
     LoggerFactory = loggerFactory;
     Activator     = new JobActivator(gatewayClient);
     Request       = new ActivateJobsRequest();
     JobClient     = zeebeClient;
     ThreadCount   = 1;
 }
        public JobWorkerBuilder(
            IZeebeClient zeebeClient,
            ILoggerFactory loggerFactory = null)
        {
            LoggerFactory = loggerFactory;
            Command       = (ActivateJobsCommand)zeebeClient.NewActivateJobsCommand();
            JobClient     = zeebeClient;
            ThreadCount   = 1;

            zeebeClient.NewActivateJobsCommand();
        }
Пример #10
0
        public ZeebeService(ILogger <ZeebeService> logger, IBusinessService businessService, IServerEventService eventService)
        {
            _logger             = logger;
            _businessService    = businessService;
            _serverEventService = eventService;

            _client =
                ZeebeClient.Builder()
                .UseGatewayAddress("0.0.0.0:26500")
                .UsePlainText()
                .Build();
        }
Пример #11
0
        public void Init()
        {
            server = new Server();
            server.Ports.Add(new ServerPort("localhost", 26500, ServerCredentials.Insecure));

            testService = new GatewayTestService();
            var serviceDefinition = Gateway.BindService(testService);
            server.Services.Add(serviceDefinition);
            server.Start();

            client = Client.ZeebeClient.NewZeebeClient("localhost:26500");
        }
Пример #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="zeebeUrl"></param>
        public ZeebeContext(string zeebeUrl)
        {
            //var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            //Console.WriteLine(path);

            Client = ZeebeClient.Builder()
                     .UseGatewayAddress(zeebeUrl)
                     .UsePlainText()
                     //.UseTransportEncryption($"{path}/admin.pem")
                     .Build();
        }
Пример #13
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
                });
            }
        }
Пример #14
0
        public void Init()
        {
            GrpcEnvironment.SetLogger(new ConsoleLogger());
            server = new Server();
            server.Ports.Add(new ServerPort("localhost", 26500, ServerCredentials.Insecure));

            testService = new GatewayTestService();
            var serviceDefinition = Gateway.BindService(testService);

            server.Services.Add(serviceDefinition);
            server.Start();

            client = Client.ZeebeClient.Builder().UseGatewayAddress("localhost:26500").UsePlainText().Build();
        }
Пример #15
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();
        }
Пример #16
0
    public Canary(ZeebeCanaryOptions options)
    {
        this.CanaryId = options.CanaryId;
        this.ChirpUrl = options.ChirpUrl;
        this.Debug    = options.Debug;
        this.HeartbeatPeriodSeconds = options.HeartbeatPeriodSeconds;
        this.SquawkUrl = options.SquawkUrl;

        this.zeebeClient = Zeebe.Client.ZeebeClient
                           .Builder()
                           .UseGatewayAddress("localhost:26500")
                           .UsePlainText()
                           .Build();
        using (var signal = new EventWaitHandle(false, EventResetMode.AutoReset))
        {
            this.startWorker();
            signal.WaitOne();
        }
    }
        static void Main(string[] _)
        {
            IZeebeClient client = CamundaCloudClientBuilder.Builder()
                                  .UseClientId("Yx6Q63H1Nx~tztL-tGo~tAqJfzLI6pkx")
                                  .UseClientSecret("Qj0cv6CYTc5lmYLIlsbv7XhvPMLU--jJbf~loZywSf3UFeULrGoqtV.0-mj85q2R")
                                  .UseContactPoint("9cfc0e64-b2f5-47ee-af0d-64c24341f4b7.zeebe.camunda.io:443")
                                  .Build();

            client.NewWorker()
            .JobType("celebrate")
            .Handler(JobHandler)
            .MaxJobsActive(3)
            .Timeout(TimeSpan.FromSeconds(10))
            .PollInterval(TimeSpan.FromMinutes(1))
            .PollingTimeout(TimeSpan.FromSeconds(30))
            .Name("CSharpWorker")
            .Open();

            Console.Write("Type any key to stop");
            Console.ReadLine();
        }
Пример #18
0
        public ZeebeService(BpmServerConnectionSettings bpmOptions)
        {
            var validator = new BpmServerConnectionSettingsValidator();

            validator.ValidateAndThrow(bpmOptions);

            //Discard any potential :443 port at the end
            char[] port     = { '4', '3', ':' };
            var    audience = bpmOptions.Address.TrimEnd(port);

            _client =
                ZeebeClient.Builder()
                .UseGatewayAddress(bpmOptions.Address)
                .UseTransportEncryption()
                .UseAccessTokenSupplier(
                    CamundaCloudTokenProvider.Builder()
                    .UseAuthServer(bpmOptions.AuthServer)
                    .UseClientId(bpmOptions.ClientId)
                    .UseClientSecret(bpmOptions.ClientSecret)
                    .UseAudience(audience)
                    .Build())
                .Build();
        }
Пример #19
0
 public RunOptimizationWorker(IZeebeClient client, ILogger <RunOptimizationWorker> logger)
 {
     _client = client;
     _logger = logger;
 }
Пример #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="zeebeContext"></param>
 public CreatePaymentLinkJob(IZeebeClient zeebeClient) => _zeebeClient = zeebeClient;
Пример #21
0
 public ZeebeWorkCreator(IZeebeClient client)
 {
     this._client = client;
 }
Пример #22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="zeebeContext"></param>
 public PaymentJob(IZeebeClient zeebeClient) => _zeebeClient = zeebeClient;
 public ExecutePlanWorker(IZeebeClient client, ILogger <ExecutePlanWorker> logger)
 {
     _client = client;
     _logger = logger;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="zeebeContext"></param>
 public PaymentLinkNotificationJob(IZeebeClient zeebeClient) => _zeebeClient = zeebeClient;
Пример #25
0
 public ZeebeWorker(IZeebeClient client, ILogger <ZeebeWorker> logger)
 {
     this._client = client;
     this._logger = logger;
 }
 public PriceforecasterWorker(IZeebeClient client, ILogger <PriceforecasterWorker> logger)
 {
     _client = client;
     _logger = logger;
 }
Пример #27
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="zeebeContext"></param>
 public EmailJob(IZeebeClient zeebeClient) => _zeebeClient = zeebeClient;
Пример #28
0
 public async Task Setup()
 {
     zeebeClient = await testHelper.SetupIntegrationTest();
 }
Пример #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="zeebeContext"></param>
 public ShipmentJob(IZeebeClient zeebeClient) => _zeebeClient = zeebeClient;