Skip to content

jwulf/zeebe-client-csharp

 
 

Repository files navigation

Build Status Total alerts

Zeebe C# client

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.

Requirements

  • .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 (0.17.0)

How to use

The Zeebe C# client is available via nuget (https://www.nuget.org/packages/zb-client/).

How to build

Simply run msbuild Zeebe.sln or dotnet build Zeebe.sln

Current supported Features

  • 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
  • List all workflows
  • Request a workflow resource

Examples

To create a client use this:

  var zeebeClient = ZeebeClient.NewZeebeClient("localhost:26500");

Request topology

  ITopology top = await zeebeClient.TopologyRequest().Send(); 

Create an job worker

  zeebeClient.NewWorker()
      .JobType("bar")
      .Handler((client, job) =>
      {
        // business logic
      })
      .MaxJobsActive(5)
      .Name("zb-worker")
      .PollInterval(TimeSpan.FromSeconds(5))
      .Timeout(10_000L)
      .Open();

Activate Jobs

  zeebeClient.NewActivateJobsCommand()
             .JobType("foo")
             .MaxJobsToActivate(3)
             .Timeout(TimeSpan.FromSeconds(10))
             .WorkerName("jobWorker")
             .FetchVariables("foo", "bar")
             .Send();

Complete an job

client.NewCompleteJobCommand(JobKey).Variables("{\"foo\":23}").Send();

Fail an job

client.NewFailCommand(job.Key).Retries(job.Retries - 1).ErrorMessage("This job failed.").Send();

Deploy a resource

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

Create a workflow instance

var workflowKey = deployResponse.Workflows[0].WorkflowKey;
var workflowInstanceResponse = await client
    .NewCreateWorkflowInstanceCommand()
    .WorkflowKey(workflowKey)
    .Variables("{\"foo\":\"123\"}")
    .Send();

Set variables on an element instance

await client.NewSetVariablesCommand(workflowInstanceResponse.WorkflowInstanceKey)
    .Variables("{\"a\":\"newValue\"}")
    .Send();

Update retries of an job

await client.NewUpdateRetriesCommand(45).Retries(2).Send();

Resolve an existing incident

await client.NewResolveIncidentCommand(17).Send();

Cancel an existing workflow instance

await client.NewCancelInstanceCommand(workflowInstanceResponse.WorkflowInstanceKey).Send();

List all workflows

var workflowListResponse = await client.NewListWorkflowRequest().Send();

Request workflow resource

var workflowResourceResponse = await client.NewWorkflowResourceRequest().BpmnProcessId("ship-parcel").LatestVersion().Send();

About

Contains an zeebe c# client implementation.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.5%
  • Shell 0.5%