zb-client-bootstrap 0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package zb-client-bootstrap --version 0.0.2                
NuGet\Install-Package zb-client-bootstrap -Version 0.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="zb-client-bootstrap" Version="0.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add zb-client-bootstrap --version 0.0.2                
#r "nuget: zb-client-bootstrap, 0.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install zb-client-bootstrap as a Cake Addin
#addin nuget:?package=zb-client-bootstrap&version=0.0.2

// Install zb-client-bootstrap as a Cake Tool
#tool nuget:?package=zb-client-bootstrap&version=0.0.2                

Build Status alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image Total alerts alternate text is missing from this package README image

Boostrap extension for the C# Zeebe client

This project is an extension of the C# Zeebe client project. Zeebe Job handlers are automaticly recognized and boostrapped via a .Net HostedService.

Requirements

How to use

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

See examples for more information.

Quick start

All classes which implement IJobHandler<TJob>, IJobHandler<TJob, TResponse>, IAsyncJobHandler<TJob> or IAsyncJobHandler<TJob, TResponse> are automaticly found and boostrapped when you register this boostrap project with the IServiceCollection.BoostrapZeebe() method.

The BoostrapZeebe method has two parameters:

  1. ZeebeBootstrapOptions via Configuration, Action delegate or both.
  2. An array with assembly filters, only assemblies which start with one of the filters will be scanned for job handlers.
ConfigureServices((hostContext, services) => {
    services.BootstrapZeebe(
        hostContext.Configuration.GetSection("ZeebeBootstrap"),
        "SimpleAsyncExample"
    );
})

Job

The job is an implementation of AbstractJob. A job can be configured via optional attributes. By default the simple name of the job is mapped to BPMN task job type. Job types must be unique.

public class SimpleJob : AbstractJob
{
    public SimpleJob(IJob job) 
        : base(job)
    { 
        //Variable mapping logic can be added here.
    }
}

Job handler

The job handler is an implementation of IJobHandler<TJob>, IJobHandler<TJob, TResponse>, IAsyncJobHandler<TJob> or IAsyncJobHandler<TJob, TResponse>. A jobhandler can be configured via optional attributes. Job handlers are automaticly added to the DI container, therefore you can use dependency injection inside the job handlers.

public class SimpleJobHandler : IAsyncJobHandler<SimpleJob>
{
    public async Task HandleJob(SimpleJob job, CancellationToken cancellationToken)
    {  
        await Usecase.ExecuteAsync();
    }
}

A handled job has three outcomes:

  1. The job has been handled without exceptions: this will automaticly result in a JobCompletedCommand beeing send to the broker. The TResponse is automaticly serialized and added to the JobCompletedCommand.
  2. An exception has been thrown while handling the job and the exception implements AbstractJobException: this wil automaticly result in a ThrowErrorCommand beeing send to the broker;
  3. Any other exception will automaticly result in a FailCommand beeing send to the broker;

Conventions

This project uses the following conventions:

  1. By default the simple name of the AbstractJob implementation is used to match the Type which is specified in the BPMN model. This can be overriden by adding the JobTypeAttribute to the AbstractJob implementation, see attributes for more information.
  2. By default the assembly name which contains the job handler is used as the Worker name. This can be overriden by adding the WorkerNameAttribute to the AbstractJob implementation, see attributes for more information.
  3. By default the job handlers are added to de DI container with a Transient service lifetime. This can be overriden by adding the ServiceLifetimeAttribute to the job handler, see attributes for more information.
  4. By default the ZeebeVariablesSerializer is registered as the implementation for IZeebeVariablesSerializer which uses System.Text.Json.JsonSerializer. You can override this registration by registering your service after the BootstrapZeebe method or you can register System.Text.Json.JsonSerializerOptions to configure the System.Text.Json.JsonSerializer.

How to build

Run dotnet build Zeebe.Client.Bootstrap.sln

How to test

Run dotnet test Zeebe.Client.Bootstrap.sln

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 11,663 9/21/2022
0.1.5 3,885 7/29/2022
0.1.4 425 7/29/2022
0.1.3 16,616 2/12/2022
0.1.2 534 2/2/2022
0.1.1 1,359 12/1/2021
0.1.0 365 11/17/2021
0.0.8 7,600 10/24/2021
0.0.7 320 10/21/2021
0.0.6 368 10/12/2021
0.0.5 327 10/12/2021
0.0.4 321 9/29/2021
0.0.3 339 9/6/2021
0.0.2 353 9/3/2021
0.0.1 328 9/2/2021
0.0.1-preview010 212 8/25/2021
0.0.1-preview007 211 8/25/2021
0.0.1-preview006 214 8/25/2021
0.0.1-preview005 221 8/23/2021