zeebe-redis-connector 1.0.1

dotnet add package zeebe-redis-connector --version 1.0.1                
NuGet\Install-Package zeebe-redis-connector -Version 1.0.1                
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="zeebe-redis-connector" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add zeebe-redis-connector --version 1.0.1                
#r "nuget: zeebe-redis-connector, 1.0.1"                
#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 zeebe-redis-connector as a Cake Addin
#addin nuget:?package=zeebe-redis-connector&version=1.0.1

// Install zeebe-redis-connector as a Cake Tool
#tool nuget:?package=zeebe-redis-connector&version=1.0.1                

C# Zeebe Redis Connector

This library enables the retrieval of Zeebe events with C#. It is based on StackExchange.Redis and requires the configuration of the Zeebe Exporter as described in the main project on Camunda Community Hub (camunda-community-hub/zeebe-redis-exporter).

Current limitations:

  • The connector uses a Multi-key operation to receive events from Redis and thus does not yet work with Redis Clusters.
  • StackExchange.Redis does not yet support blocking operations - hence this library is forced to use polling.
  • It is - not yet - possible to configure a stream prefix other than the default. For now this is hardwired to zeebe:.

Requirements

Usage

The Zeebe Redis Connector extension is available via nuget (https://www.nuget.org/packages/zeebe-redis-connector/).

Bootstrap

The library provides an extension IServiceCollection.AddZeebeRedis(...) for hosted services in order to bootstrap the connector. It requires ZeebeRedisOptions.

You can either wire your options manually

ConfigureServices((hostContext, services) => {
    services.AddZeebeRedis(options => {
        options.RedisConfigString = "localhost";
        options.RedisConsumerGroup = "my-consumer-group";
        options.RedisPollIntervallMillis = 500;
    })
    .AddSingleton<ZeebeRedisListener>()
    .AddHostedService(p => p.GetRequiredService<ZeebeRedisListener>());
})

or use a corresponding configuration section

ConfigureServices((hostContext, services) => {
    services.AddZeebeRedis(
        hostContext.Configuration.GetSection("ZeebeRedisConfiguration")
    })
    .AddSingleton<ZeebeRedisListener>()
    .AddHostedService(p => p.GetRequiredService<ZeebeRedisListener>());
})

with

{
  "ZeebeRedisConfiguration": {
    "RedisConfigString": "localhost",
    "RedisConsumerGroup": "my-csharp-consumer",
    "RedisPollIntervallMillis" : 500
  }
}

Lastly, it is also possible to use environment variables:

ConfigureServices((hostContext, services) => {
    services.AddZeebeRedis()
    .AddSingleton<ZeebeRedisListener>()
    .AddHostedService(p => p.GetRequiredService<ZeebeRedisListener>());
})
Environment Parameter Description
REDIS_CONFIG_STRING Redis URL as required by StackExchange.Redis. Default: localhost
REDIS_CONSUMER_GROUP The consumer group. Default: empty
REDIS_POLL_INTERVALL_MILLIS Poll interval in milliseconds. Default: 500

Environment variables always have precedence over other ways of configuration.

Hint: It is strongly recommended to set the consumer group name. Otherwise, you will get a unique disposable group generated at startup.

Registering Zeebe Event Listeners

By injecting ZeebeRedis in one of your services you're able to register listeners for specific events. Registering listeners should happen before the startup of your application - e.g. in the constructor of an IHostedService.

public class ZeebeRedisListener : IHostedService
{
    public ZeebeRedisListener(ZeebeRedis zeebeRedis) {
        zeebeRedis
            .AddDeploymentListener((deployment) => ReceiveDeploymentRecord(deployment))
            .AddIncidentListener((incident) => ...)
            .AddJobListener((job) => ...)
            ...
            ;
    }

    public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
    public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;

    private void ReceiveDeploymentRecord(DeploymentRecord deploymentRecord)
    {
        ...
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.1 150 10/23/2024
1.0.0 906 5/13/2024
0.9.11 171 2/29/2024