A cohesive set of infrastructure libraries for dotnet that utilizes abstractions for event handling, persistence, unit of work, mediator, distributed messaging, event bus, CQRS, email, and more
$ dotnet add package RCommon.MassTransitIntegrates MassTransit distributed messaging with RCommon's event handling system, allowing you to produce and consume events through MassTransit while programming against RCommon's IEventProducer and ISubscriber<T> abstractions.
ISubscriber<T> abstraction for handler portabilityIBusRegistrationConfigurator for transport and consumer configurationdotnet add package RCommon.MassTransit
using RCommon;
using RCommon.MassTransit;
builder.Services.AddRCommon()
.WithEventHandling<MassTransitEventHandlingBuilder>(eventHandling =>
{
// Register subscribers that bridge MassTransit to RCommon
eventHandling.AddSubscriber<OrderCreatedEvent, OrderCreatedEventHandler>();
// Configure MassTransit transports (full IBusRegistrationConfigurator access)
eventHandling.UsingRabbitMq((context, cfg) =>
{
cfg.Host("localhost", "/", h =>
{
h.Username("guest");
h.Password("guest");
});
cfg.ConfigureEndpoints(context);
});
});
Produce events from application code:
public class OrderService
{
private readonly IEventProducer _eventProducer;
public OrderService(IEventProducer eventProducer)
{
_eventProducer = eventProducer;
}
public async Task CreateOrderAsync(Order order)
{
// This publishes via MassTransit to all subscribed consumers
await _eventProducer.ProduceEventAsync(new OrderCreatedEvent(order));
}
}
| Type | Description |
|---|---|
PublishWithMassTransitEventProducer | IEventProducer that publishes events to all consumers via IBus.Publish (fan-out) |
SendWithMassTransitEventProducer | IEventProducer that sends events to a single endpoint via IBus.Send (point-to-point) |
MassTransitEventHandler<TEvent> | MassTransit IConsumer<T> that delegates to an RCommon ISubscriber<T> |
IMassTransitEventHandlingBuilder | Builder combining IEventHandlingBuilder with MassTransit's IBusRegistrationConfigurator |
MassTransitEventHandlingBuilder | Default builder implementation for configuring MassTransit event handling |
For full documentation, visit rcommon.com.
IEventProducer and ISubscriber<T>Licensed under the Apache License, Version 2.0.