Highlights
- Hosting through dependency injection.
services.AddObvs(...)configures the bus, andIServiceBusandIServiceBusClientcome from the container. The bus starts and stops with the host. Its configuration is checked at startup, and every problem is reported in oneObvsConfigurationException, each saying how to fix it. Without a host,ObvsBus.StartAsync(...)does the same. - Every transport configured the same way:
UseRabbitMq,UseKafka,UseNats,UseNatsJetStream,UseActiveMq,UseAzureServiceBusandUseAmazonSqs, each with an options class, from configuration or code. - New transports. Azure Service Bus and Amazon SQS and SNS, where a service's instances share its command and request queues, each bus has its own subscription to events, and messages are settled after their handler: completed, delivered again on failure, and dead-lettered after
MaxDeliveryAttempts. NATS JetStream works the same way. Kafka supports Confluent Cloud, Amazon MSK and Azure Event Hubs. - Handlers and awaitable requests:
HandleCommand,HandleEventandHandleRequest, as lambdas or classes from the container, withMaxConcurrency;RequestAsync; and the streams asIAsyncEnumerablewithReadEventsAsync. Every send takes aCancellationToken, which reaches the broker. - System.Text.Json by default, reading and writing the same JSON as v6's Newtonsoft serializer. Any serializer can be gzipped with
Compressed(). - Observability: OpenTelemetry traces and metrics, with trace context carried in each message's headers on every transport, and logging through
Microsoft.Extensions.Logging. - Testing:
Obvs.Testing's in-memory transport andObvsTestHarness, which waits for a message as soon as it's sent, with virtual time. - Analyzers, built into the
Obvspackage, report common mistakes as you type, with code fixes. - For agents: each service's contract as an AsyncAPI document, a test that catches breaking contract changes, an MCP server for development buses,
llms.txt, and documentation whose every snippet is compiled and tested.
Before and after
Configuring the bus:
IServiceBus bus = ServiceBus.Configure()
.WithRabbitMQEndpoints<IOrderMessage>()
.Named("orders")
.ConnectToBroker("amqp://localhost:5672")
.SerializedAsJson()
.AsClientAndServer()
.UsingConsoleLogging()
.Create();
builder.Services.AddObvs(obvs => obvs
.AddService<IOrderMessage>("orders", service => service
.UseRabbitMq(options => options.Uri = new Uri("amqp://localhost:5672"))));
// IServiceBus and IServiceBusClient are in the container. The bus starts with the host.
Handling a command:
bus.Commands.OfType<PlaceOrder>().Subscribe(async command =>
{
await bus.PublishAsync(new OrderPlaced(command.OrderId));
});
service.HandleCommand<PlaceOrder>(async (command, context, ct) =>
{
await context.PublishAsync(new OrderPlaced(command.OrderId), ct);
});
// Or a class from the container
service.HandleCommand<PlaceOrder, PlaceOrderHandler>();
Making a request. The v6 way still works in v7, and a request that names its response, as GetQuote : IRequest<Quote> does, can be awaited:
var quote = await bus.GetResponses(new GetQuote("sku-1"))
.OfType<Quote>().Take(1).Timeout(TimeSpan.FromSeconds(5)).ToTask();
var quote = await client.RequestAsync(
new GetQuote("sku-1"), TimeSpan.FromSeconds(5), ct);
What changed since v6
- Configuration.
ServiceBus.Configure()and each transport's fluent configuration are gone: useAddObvsandUse<Transport>(...), orObvsBus.StartAsync(...)without a host. - Packages. The MsgPack.Cli, NetJSON, XML and YAML serializers,
Obvs.Monitoring.*andObvs.Logging.NLogstay on v6: use System.Text.Json, OpenTelemetry andMicrosoft.Extensions.Logging.Obvs.Serialization.MessagePackis now MessagePack-CSharp. - Target frameworks: net472, netstandard2.0 and net10.0.
The migration guide has the details: before and after for each change, and what v6 and v7 apps on one broker share.