using System;
using System.Threading.Tasks;
using NLog.Extensions.Logging;
using Zeebe.Client.Impl.Builder;
namespace Client.Cloud.Example
{
public class Program
{
public static async Task Main(string[] args)
{
var zeebeClient =
CamundaCloudClientBuilder.Builder()
.UseClientId("ZEEBE_CLIENT_ID")
.UseClientSecret("ZEEBE_CLIENT_SECRET")
.UseContactPoint("ZEEBE_ADDRESS")
.UseLoggerFactory(new NLogLoggerFactory())
.Build();
var topology = await zeebeClient.TopologyRequest().Send();
Console.WriteLine("Hello: " + topology);
}
}
}
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using NLog.Extensions.Logging;
namespace Client.Examples
{
internal class Program
{
private static readonly string DemoProcessPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "demo-process.bpmn");
private static readonly string ZeebeUrl = "0.0.0.0:26500";
private static readonly string ProcessInstanceVariables = "{\"a\":\"123\"}";
private static readonly string JobType = "payment-service";
private static readonly string WorkerName = Environment.MachineName;
private static readonly long WorkCount = 100L;
public static async Task Main(string[] args)
{
var client = ZeebeClient.Builder()
.UseLoggerFactory(new NLogLoggerFactory())
.UseGatewayAddress(ZeebeUrl)
.UsePlainText()
.Build();
var topology = await client.TopologyRequest()
.Send();
Console.WriteLine(topology);
await client.NewPublishMessageCommand()
.MessageName("csharp")
.CorrelationKey("wow")
.Variables("{\"realValue\":2}")
.Send();
var deployResponse = await client.NewDeployCommand()
.AddResourceFile(DemoProcessPath)
.Send();
var processDefinitionKey = deployResponse.Processes[0].ProcessDefinitionKey;
var processInstance = await client
.NewCreateProcessInstanceCommand()
.ProcessDefinitionKey(processDefinitionKey)
.Variables(ProcessInstanceVariables)
.Send();
await client.NewSetVariablesCommand(processInstance.ProcessInstanceKey).Variables("{\"wow\":\"this\"}").Local().Send();
for (var i = 0; i < WorkCount; i++)
{
await client
.NewCreateProcessInstanceCommand()
.ProcessDefinitionKey(processDefinitionKey)
.Variables(ProcessInstanceVariables)
.Send();
}
using (var signal = new EventWaitHandle(false, EventResetMode.AutoReset))
{
client.NewWorker()
.JobType(JobType)
.Handler(HandleJob)
.MaxJobsActive(5)
.Name(WorkerName)
.AutoCompletion()
.PollInterval(TimeSpan.FromSeconds(1))
.Timeout(TimeSpan.FromSeconds(10))
.Open();
signal.WaitOne();
}
}
{
Console.WriteLine("Handling job: " + job);
if (jobKey % 3 == 0)
{
.Variables("{\"foo\":2}")
.Send()
.GetAwaiter()
.GetResult();
}
else if (jobKey % 2 == 0)
{
.ErrorMessage("Example fail")
.Send()
.GetAwaiter()
.GetResult();
}
else
{
}
}
}
}
int Retries
remaining retries
Definition IJob.cs:50
long Key
The unique key of the job
Definition IJob.cs:23
A client with access to all job-related operation: complete a job mark a job as failed update the ret...
Definition IJobClient.cs:30
ICompleteJobCommandStep1 NewCompleteJobCommand(long jobKey)
Command to complete a job.
IFailJobCommandStep1 NewFailCommand(long jobKey)
Command to mark a job as failed.
Definition IActivateJobsResponse.cs:18
Definition IJobClient.cs:20
Definition IAccessTokenSupplier.cs:4