The Zeebe C# client is a C# wrapper implementation around the GRPC (https://github.com/grpc/grpc) generated Zeebe client. It makes it possible to communicate with Zeebe Broker via the GRPC protocol, see the Zeebe documentation for more information about the Zeebe project.
- .net standard 2.0 or higher, which means
- .net core 2.1 or higher or
- .net framework 4.7.1 or higher
- latest Zeebe release
The Zeebe C# client is available via nuget (https://www.nuget.org/packages/zb-client/).
The Zeebe C# Client is Camunda Cloud ready. To get an example how to use the Zeebe C# Client with the Cloud take a look at Client.Examples/CloudExample.cs.md.
Simply run msbuild Zeebe.sln
or dotnet build Zeebe.sln
- Request topology
- JobWorker
- Activate Jobs
- Complete Job
- Fail Job
- Publish Message
- Deploy an resource
- Create a workflow instance
- Set variables on an element instance
- Update retries of an job
- Resolve an existing incident
- Cancel an existing workflow instance
There exist an example project under Client.Examples/
, which contains some of the examples below.
You can run the example with the following command:
dotnet run --project Client.Examples/Client.Examples.csproj
Make sure that you have an broker runing before you execute the examples. Easiest way to run an broker is to use docker, see the following command:
docker run -p 26500:26500 camunda/zeebe:latest
To create a client use this:
var zeebeClient = ZeebeClient.NewZeebeClient("localhost:26500");
ITopology top = await zeebeClient.TopologyRequest().Send();
zeebeClient.NewWorker()
.JobType("bar")
.Handler((client, job) =>
{
// business logic
})
.MaxJobsActive(5)
.Name("zb-worker")
.PollInterval(TimeSpan.FromSeconds(5))
.Timeout(10_000L)
.Open();
zeebeClient.NewActivateJobsCommand()
.JobType("foo")
.MaxJobsToActivate(3)
.Timeout(TimeSpan.FromSeconds(10))
.WorkerName("jobWorker")
.FetchVariables("foo", "bar")
.Send();
client.NewCompleteJobCommand(JobKey).Variables("{\"foo\":23}").Send();
client.NewFailCommand(job.Key).Retries(job.Retries - 1).ErrorMessage("This job failed.").Send();
var deployResponse = await client.NewDeployCommand().AddResourceFile(DemoProcessPath).Send();
var workflowKey = deployResponse.Workflows[0].WorkflowKey;
var workflowInstanceResponse = await client
.NewCreateWorkflowInstanceCommand()
.WorkflowKey(workflowKey)
.Variables("{\"foo\":\"123\"}")
.Send();
await client.NewSetVariablesCommand(workflowInstanceResponse.WorkflowInstanceKey)
.Variables("{\"a\":\"newValue\"}")
.Send();
await client.NewUpdateRetriesCommand(45).Retries(2).Send();
await client.NewResolveIncidentCommand(17).Send();
await client.NewCancelInstanceCommand(workflowInstanceResponse.WorkflowInstanceKey).Send();