zb-client-bootstrap 0.0.1-preview006

This is a prerelease version of zb-client-bootstrap.
There is a newer version of this package available.
See the version list below for details.
Install-Package zb-client-bootstrap -Version 0.0.1-preview006
dotnet add package zb-client-bootstrap --version 0.0.1-preview006
<PackageReference Include="zb-client-bootstrap" Version="0.0.1-preview006" />
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.1-preview006
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: zb-client-bootstrap, 0.0.1-preview006"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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.1-preview006&prerelease

// Install zb-client-bootstrap as a Cake Tool
#tool nuget:?package=zb-client-bootstrap&version=0.0.1-preview006&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Build Status Total alerts

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/).

Ze examples for more information.

Quick start

All classes which implement IJobHandler<T> or IAsyncJobHandler<T> are automaticly found and boostrapped when you register this boostrap project with the IServiceCollection extension method BoostrapZeebe.

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.

Appsettings configuration

ConfigureServices((hostContext, services) => {
    services.BootstrapZeebe(
        hostContext.Configuration.GetSection("ZeebeBootstrap"),
        "SimpleExample"
    );
})

appsettings.json

{
    "ZeebeBootstrap": {
        "Client": {                
            "GatewayAddress": "0.0.0.0:26500"
        },
        "Worker": {
            "MaxJobsActive": 1,
            "TimeoutInMilliseconds": 500,
            "PollIntervalInMilliseconds": 10000,
            "PollingTimeoutInMilliseconds": 30000
        }
    }
}

Delegate configuration

ConfigureServices((hostContext, services) => {
    services.BootstrapZeebe(
        options => { 
            options => { 
                options.Client = new ClientOptions() {
                    GatewayAddress = "0.0.0.0:26500"
                };
                options.Worker = new WorkerOptions() 
                {
                    MaxJobsActive = 1,
                    TimeoutInMilliseconds = 10000,
                    PollIntervalInMilliseconds = 30000,
                    PollingTimeoutInMilliseconds = 1000
                };
            }
        },
        "SimpleExample"
    );
})

Job

The job is an implementation of AbstractJob. A job can be configured via optional attributes. Job types must be unique.

[JobType("SimpleJobV2")]
[WorkerName("SimpleWorker")]
[MaxJobsActive(2)]
[Timeout(500)]
[PollInterval(10000)]
[PollingTimeout(500)]
class SimpleJob : AbstractJob
{
    public SimpleJob(IJob job) : base(job)
    { }
}

Job handler

The job handler is an implementation of IJobHandler<T> or IAsyncJobHandler<T>. A job 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.

[ServiceLifetime(ServiceLifetime.Singleton)]
class SimpleJobHandler : IAsyncJobHandler<SimpleJob>
{
    public Task HandleJob(IJobClient client, SimpleJob job, CancellationToken cancellationToken)
    {  
        return client.NewCompleteJobCommand(job.Key).Send();
    }
}

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.
  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.
  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.

How to build

Run dotnet build Zeebe.Client.Bootstrap.sln.

How to test

Run dotnet test Zeebe.Client.Bootstrap.sln.

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
0.1.0 76 11/17/2021
0.0.8 206 10/24/2021
0.0.7 88 10/21/2021
0.0.6 95 10/12/2021
0.0.5 77 10/12/2021
0.0.4 79 9/29/2021
0.0.3 82 9/6/2021
0.0.2 86 9/3/2021
0.0.1 85 9/2/2021
0.0.1-preview010 64 8/25/2021
0.0.1-preview007 54 8/25/2021
0.0.1-preview006 59 8/25/2021
0.0.1-preview005 61 8/23/2021