EventFlux.RedisFlow 1.0.2

dotnet add package EventFlux.RedisFlow --version 1.0.2
                    
NuGet\Install-Package EventFlux.RedisFlow -Version 1.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="EventFlux.RedisFlow" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EventFlux.RedisFlow" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="EventFlux.RedisFlow" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EventFlux.RedisFlow --version 1.0.2
                    
#r "nuget: EventFlux.RedisFlow, 1.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.
#:package EventFlux.RedisFlow@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EventFlux.RedisFlow&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=EventFlux.RedisFlow&version=1.0.2
                    
Install as a Cake Tool

EventFlux.RedisFlow

Lightweight helper library for publishing and consuming EventFlux events via Redis Streams. This library provides a small opinionated host integration: a Redis stream publisher, a background worker that reads stream entries, resolves event types, publishes to EventFlux's IEventBus and invokes local handlers.

Features

  • Publish to Redis streams: IRedisStreamPublisher.PublishAsync(eventType, payload) helper.
  • Background consumer worker: RedisStreamWorker reads Redis streams, resolves event types, and publishes to EventFlux.
  • Automatic handler registration: AddRedisEventQueue(...) scans assemblies you pass and registers IEventHandler<T> implementations.
  • Flexible type resolution: resolves registered types by name and falls back to a GenericEvent when the concrete type isn't available.
  • Consumer group per instance option: append machine-name or GUID to ConsumerGroup to allow multiple independent consumers to process the same stream.
  • Ack + optional delete: worker acknowledges processed entries and (optionally) deletes them to avoid reprocessing on restarts.
  • Startup diagnostics: logs discovered event types and handler registrations to help debugging.

Quick Start

  1. Add a project reference to the library (or package):

    • In your API project the NuGet package is EvenFlux.RedisFlow.
  2. Configure Redis stream settings in appsettings.json:

{
  "RedisStream": {
    "ConnectionString": "localhost:6379",
    "StreamName": "event-stream",
    "ConsumerGroup": "event-group",
    "ConsumerName": "consumer-1",
    "BatchSize": 10
  }
}
  1. Register the integration in Program.cs:
// Register and scan your assembly for event types and handlers
builder.Services.AddRedisEventQueue(
    builder.Configuration,
    assemblies: new[] { typeof(Program).Assembly },
    appendGuidToConsumerGroup: true // optional: make group unique per instance
);
  1. Publish from any project that references the library by using IRedisStreamPublisher:
app.MapPost("/publish", async (MyEvent req, IRedisStreamPublisher publisher) =>
{
    var payload = JsonConvert.SerializeObject(req);
    await publisher.PublishAsync(nameof(MyEvent), payload);
    return Results.Ok();
});
  1. In consumer projects define your event and handler types locally:
public class MyEvent : IEventRequest { public string Data { get; set; } }

public class MyEventHandler : IEventHandler<MyEvent>
{
    public async Task Handle(MyEvent request)
    {
        // handle
    }
}
  1. Access event context inside your event handlers:
  • If your producer sends an event context (version, configs, tenant info, etc.), you can access it inside your handler using IEventContextAccessor.
public class PublishEventHandler : IEventHandler<PublishEventRequest>
{
    private readonly IEventContextAccessor _contextAccessor;

    public PublishEventHandler(IEventContextAccessor contextAccessor)
    {
        _contextAccessor = contextAccessor;
    }

    public async Task Handle(PublishEventRequest request)
    {
        var context = _contextAccessor.EventContext;

        if (context != null)
        {
            Console.WriteLine($"Context Version: {context.Version}");

            if (context.Configs != null)
            {
                foreach (var cfg in context.Configs)
                {
                    Console.WriteLine($"{cfg.Key}: {cfg.Value}");
                }
            }
        }

        // handle event logic
    }
}

The library's AddRedisEventQueue(...) will scan the assembly you pass and register IEventHandler<T> implementations automatically.

Behavior and important details

  • Type resolution: the worker reads type and data fields from Redis stream entries. It attempts to resolve the type name to a CLR type using registered event types (from assemblies you passed). If not found, it publishes a GenericEvent (with EventName and RawPayload).

  • Handler dispatch: EventFlux's IEventBus dispatches the event object. The handler must be registered in DI as IEventHandler<T> for the concrete T used by the publisher; AddRedisEventQueue auto-registers handlers found in scanned assemblies.

  • Consumer groups: Redis consumer groups distribute messages across group members. If multiple services use the same ConsumerGroup, messages will be load-balanced (each message delivered to only one member). If you want multiple independent services to receive the same messages, give each service a distinct ConsumerGroup (use appendGuidToConsumerGroup or set unique ConsumerGroup values per app).

  • Acknowledgement and deletion: the worker acknowledges processed entries with XACK. The library also deletes entries from the stream after ack to avoid reprocessing on restart. If you prefer to keep entries for audit, you can modify the worker to skip deletion and rely on XACK only.

Advanced options

  • AddRedisEventQueue(..., appendMachineNameToConsumerGroup: true) — append the machine name to ConsumerGroup so each instance has a per-host group.
  • AddRedisEventQueue(..., appendGuidToConsumerGroup: true) — append a GUID to ConsumerGroup so each instance is independent (useful for local testing).
  • Handler lifetime: by default handlers are registered as Transient. If handlers need scoped services, change registration to AddScoped in ServiceCollectionExtensions.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.2 148 12/20/2025
1.0.1 319 12/7/2025