Wolverine
Wolverine event handling implementation in RCommon.
Overview
Most enterprise applications have a need for a simple in-memory event bus which implements the observer pattern through the pub/sub pattern. RCommon implements a simple dependency-free event bus for this utility but there are some advantages to using Wolverine. Wolverine is a feature rich event bus/message bus implementation that offers event durability, multi-tenancy, among other useful utilities in distributed applications.
Configuration
using Examples.Messaging.Wolverine;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using RCommon;
using RCommon.EventHandling;
using RCommon.EventHandling.Producers;
using RCommon.Wolverine.Producers;
using System.Diagnostics;
using Wolverine;
try
{
var host = Host.CreateDefaultBuilder(args)
.UseWolverine(options =>
{
options.LocalQueue("test");
})
.ConfigureAppConfiguration((context, builder) =>
{
ConfigurationContainer.Configuration = builder
.Build();
})
.ConfigureServices(services =>
{
// Configure RCommon
services.AddRCommon()
.WithEventHandling<WolverineEventHandlingBuilder>(eventHandling =>
{
eventHandling.AddProducer<PublishWithWolverineEventProducer>();
eventHandling.AddSubscriber<TestEvent, TestEventHandler>();
});
}).Build();
await host.StartAsync();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Implementation
Producing the Event
Subscribing to the Event
Event Handling: WolverineLast updated