Commands, events, requests and responses over RabbitMQ, Kafka, NATS, ActiveMQ, Azure Service Bus or Amazon SQS, with handlers, awaitable requests and Reactive Extensions streams.
dotnet add package Obvs
builder.Services.AddObvs(obvs => obvs
.AddService<IOrderMessage>("orders", service => service
.UseRabbitMq(options => options.Uri = new Uri("amqp://localhost:5672"))
.HandleCommand<PlaceOrder>(async (command, context, ct) =>
await context.PublishAsync(new OrderPlaced(command.OrderId), ct))
.HandleRequest<GetQuote, Quote>((request, context, ct) =>
Task.FromResult(new Quote(request.Sku, 9.99m)))));
// From anywhere with the bus
await client.SendAsync(new PlaceOrder("o-1"), ct);
var quote = await client.RequestAsync(
new GetQuote("sku-1"), TimeSpan.FromSeconds(5), ct);
Why Obvs
Writing code to connect two processes involves a lot of boilerplate, and every new service or message type repeats it. Obvs takes care of it. Define a service's messages, choose its transport, and handle them: the rest is configuration you can change without touching your handlers.
Every transport configured the same way, from configuration or code. The bus starts and stops with the host.
Run in a DI scope, settle messages on transports that keep them, and take a maximum concurrency.
Await a request's response, and read the bus's streams as Rx observables or IAsyncEnumerable.
System.Text.Json by default, or Newtonsoft JSON, MessagePack or ProtoBuf, any of them gzipped.
Traces and metrics, with each message's trace carried from sender to handler.
Every configuration problem reported at once, each with its fix.
Catch common mistakes as you type, with code fixes, built into the Obvs package.
An in-memory transport and test harness that waits for messages without fixed delays.
Each service's contract as an AsyncAPI document, and an MCP server so agents can inspect and drive a development bus.
Quick start
Add the packages, define the service's messages, host it, and use it.
Obvs, and a transport.
dotnet add package Obvs
dotnet add package Obvs.RabbitMQ
Each is a command, an event, a request or a response.
// Every message of a service implements its interface,
// and is one of ICommand, IEvent, IRequest or IResponse.
// A request names the response that answers it.
public interface IOrderMessage : IMessage { }
public record PlaceOrder(string OrderId) : IOrderMessage, ICommand;
public record OrderPlaced(string OrderId) : IOrderMessage, IEvent;
public record GetQuote(string Sku) : IOrderMessage, IRequest<Quote>
{
public string RequestId { get; set; }
public string RequesterId { get; set; }
}
public record Quote(string Sku, decimal Price) : IOrderMessage, IResponse
{
public string RequestId { get; set; }
public string RequesterId { get; set; }
}
It handles commands and requests, and publishes events.
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddObvs(obvs => obvs
.AddService<IOrderMessage>("orders", service => service
.UseRabbitMq(options => options.Uri = new Uri("amqp://localhost:5672"))
.HandleCommand<PlaceOrder>(async (command, context, ct) =>
{
// ... place the order, then tell whoever's interested
await context.PublishAsync(new OrderPlaced(command.OrderId), ct);
})
.HandleRequest<GetQuote, Quote>((request, context, ct) =>
Task.FromResult(new Quote(request.Sku, 9.99m)))));
await builder.Build().RunAsync();
Send commands and await requests' responses.
var client = app.Services.GetRequiredService<IServiceBusClient>();
await client.SendAsync(new PlaceOrder("o-1"), ct);
var quote = await client.RequestAsync(new GetQuote("sku-1"), TimeSpan.FromSeconds(5), ct);
Docs
Guides on GitHub, each snippet in them compiled and tested.
v6 and v7 apps work together on the same broker, so you can move one app at a time.