MCPcopy Create free account
hub / github.com/camunda/camunda-platform-get-started / Program

Class Program

csharp/Program.cs:14–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace csharp
13{
14 class Program
15 {
16 private static readonly string ClientID = "YOUR_CLIENT_ID";
17 private static readonly string ClientSecret = "YOUR_CLIENT_SECRET";
18 private static readonly string ClusterAddress = "YOUR_CLUSTER_ID.bru-2.zeebe.camunda.io:443";
19 private static readonly ILoggerFactory LoggerFactory = new NLogLoggerFactory();
20 private static readonly ILogger<Program> Log = LoggerFactory.CreateLogger<Program>();
21 private const string LogMessage = "Started instance for" +
22 " processDefinitionKey='{processDefinitionKey}'," +
23 " bpmnProcessId='{bpmnProcessId}'," +
24 " version='{version}'" +
25 " with processInstanceKey='{processInstanceKey}'";
26
27 private const string VariablesKey = "message_content";
28 private const string VariablesValue = "Hello from the C# get started";
29
30 static async Task Main(string[] _)
31 {
32 using (var zeebeClient = CreateZeebeClient())
33 {
34 var topology = await zeebeClient.TopologyRequest().Send();
35
36 Console.WriteLine("Topology: " + topology);
37
38 await zeebeClient.NewDeployCommand().AddResourceFile("send-email.bpmn").Send();
39
40 var variables = $"{{\"{VariablesKey}\":\"{VariablesValue}\"}}";
41 var processInstanceResponse = await zeebeClient
42 .NewCreateProcessInstanceCommand()
43 .BpmnProcessId("send-email")
44 .LatestVersion()
45 .Variables(variables).Send();
46
47 Log.LogInformation(LogMessage,
48 processInstanceResponse.ProcessDefinitionKey,
49 processInstanceResponse.BpmnProcessId,
50 processInstanceResponse.Version,
51 processInstanceResponse.ProcessInstanceKey);
52
53 using (zeebeClient.NewWorker()
54 .JobType("email")
55 .Handler(JobHandler)
56 .MaxJobsActive(3)
57 .Timeout(TimeSpan.FromSeconds(10))
58 .PollInterval(TimeSpan.FromMinutes(1))
59 .PollingTimeout(TimeSpan.FromSeconds(30))
60 .Name("CsharpGetStartedWorker")
61 .Open())
62 {
63 AwaitExitUserCmd();
64 }
65 }
66 }
67
68
69 private static void JobHandler(IJobClient jobClient, IJob activatedJob)
70 {
71 var variables = JsonConvert.DeserializeObject<Dictionary<string, string>>(activatedJob.Variables);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected