{"id":19488597,"url":"https://github.com/zarusz/slimmessagebus","last_synced_at":"2025-05-14T02:09:05.968Z","repository":{"id":37692902,"uuid":"59224410","full_name":"zarusz/SlimMessageBus","owner":"zarusz","description":"Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.","archived":false,"fork":false,"pushed_at":"2025-04-24T22:17:39.000Z","size":22244,"stargazers_count":521,"open_issues_count":46,"forks_count":79,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-24T22:39:30.268Z","etag":null,"topics":["apache-kafka","avro","azure","azure-event-hubs","azure-service-bus","bus","c-sharp","ddd","dotnet","kafka","message-bus","messaging","mqtt","pub-sub","rabbitmq","redis","request-response"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zarusz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-05-19T16:37:25.000Z","updated_at":"2025-04-24T22:17:41.000Z","dependencies_parsed_at":"2022-08-08T21:16:12.858Z","dependency_job_id":"c05a1beb-77ec-4b91-8f9e-3f5b6ba2565c","html_url":"https://github.com/zarusz/SlimMessageBus","commit_stats":{"total_commits":480,"total_committers":8,"mean_commits":60.0,"dds":0.02083333333333337,"last_synced_commit":"b72445289c200d370f1469f61ba7bee73bba7b8f"},"previous_names":[],"tags_count":185,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zarusz%2FSlimMessageBus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zarusz%2FSlimMessageBus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zarusz%2FSlimMessageBus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zarusz%2FSlimMessageBus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zarusz","download_url":"https://codeload.github.com/zarusz/SlimMessageBus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254053240,"owners_count":22006717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-kafka","avro","azure","azure-event-hubs","azure-service-bus","bus","c-sharp","ddd","dotnet","kafka","message-bus","messaging","mqtt","pub-sub","rabbitmq","redis","request-response"],"created_at":"2024-11-10T21:04:08.958Z","updated_at":"2025-05-14T02:09:00.941Z","avatar_url":"https://github.com/zarusz.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SlimMessageBus \u003c!-- omit in toc --\u003e\n\nSlimMessageBus is a lightweight, flexible, and extensible messaging framework for .NET, supporting multiple message brokers, including Kafka, RabbitMQ, Azure EventHubs, MQTT, Redis Pub/Sub, and more. It simplifies asynchronous communication and integrates seamlessly with modern .NET applications.\n\n[![GitHub license](https://img.shields.io/github/license/zarusz/SlimMessageBus)](https://github.com/zarusz/SlimMessageBus/blob/master/LICENSE)\n[![Build](https://github.com/zarusz/SlimMessageBus/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/zarusz/SlimMessageBus/actions/workflows/build.yml)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=zarusz_SlimMessageBus\u0026metric=sqale_rating)](https://sonarcloud.io/summary/overall?id=zarusz_SlimMessageBus)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=zarusz_SlimMessageBus\u0026metric=coverage)](https://sonarcloud.io/summary/overall?id=zarusz_SlimMessageBus)\n[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=zarusz_SlimMessageBus\u0026metric=duplicated_lines_density)](https://sonarcloud.io/summary/overall?id=zarusz_SlimMessageBus)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=zarusz_SlimMessageBus\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/overall?id=zarusz_SlimMessageBus)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=zarusz_SlimMessageBus\u0026metric=alert_status)](https://sonarcloud.io/summary/overall?id=zarusz_SlimMessageBus)\n\n\u003e See how to migrate from [MediatR](/docs/UseCases/ReplaceMediatR.md) or [MassTransit](/docs/UseCases/ReplaceMassTransit.md)\n\n## 🚀 Quick Start\n\n### Installation\n\n```bash\ndotnet add package SlimMessageBus\n# Add specific transport provider, e.g. Kafka\ndotnet add package SlimMessageBus.Host.Kafka\n# Add serialization plugin\ndotnet add package SlimMessageBus.Host.Serialization.SystemTextJson\n```\n\n### Basic Usage\n\n#### Publishing Messages\n\n```csharp\nIMessageBus bus; // injected\n\npublic record OrderCreatedEvent(int OrderId);\n\nawait bus.Publish(new OrderCreatedEvent(123));\n```\n\n#### Consuming Messages\n\n```csharp\npublic class OrderCreatedEventConsumer : IConsumer\u003cOrderCreatedEvent\u003e\n{\n    public async Task OnHandle(OrderCreatedEvent message, CancellationToken cancellationToken)\n    {\n        // Handle the event\n    }\n}\n```\n\n### Request-Response Example\n\n#### Sending a Request\n\n```csharp\npublic record CreateCustomerCommand(string Name) : IRequest\u003cCreateCustomerCommandResult\u003e;\npublic record CreateCustomerCommandResult(Guid CustomerId);\n\nvar result = await bus.Send(new CreateCustomerCommand(\"John Doe\"));\n```\n\n#### Handling a Request\n\n```csharp\n\npublic class CreateCustomerCommandHandler : IRequestHandler\u003cCreateCustomerCommand, CreateCustomerCommandResult\u003e\n{\n    public async Task\u003cCreateCustomerCommandResult\u003e OnHandle(CreateCustomerCommand request, CancellationToken cancellationToken)\n    {\n        // Create customer logic\n        return new(Guid.NewGuid());\n    }\n}\n```\n\n### Configuration Example\n\n```csharp\nservices.AddSlimMessageBus(mbb =\u003e\n{\n    mbb.AddChildBus(\"Bus1\", builder =\u003e\n    {\n         builder\n               // the pub-sub events\n               .Produce\u003cOrderCreatedEvent\u003e(x =\u003e x.DefaultPath(\"orders-topic\"))\n               .Consume\u003cOrderCreatedEvent\u003e(x =\u003e x.Path(\"orders-topic\")\n                  //.WithConsumer\u003cOrderCreatedEventConsumer\u003e() // Optional: can be skipped as IConsumer\u003cOrderCreatedEvent\u003e will be resolved from DI\n                  //.KafkaGroup(\"kafka-consumer-group\") // Kafka: Consumer Group\n                  //.SubscriptionName(\"azure-sb-topic-subscription\") // Azure ServiceBus: Subscription Name\n               )\n\n               // the request-response\n               .Produce\u003cCreateCustomerCommand\u003e(x =\u003e x.DefaultPath(\"customer-requests\"))\n               .Handle\u003cCreateCustomerCommand, CreateCustomerCommandResult\u003e(x =\u003e x.Path(\"customer-requests\"))\n\n               // Use Kafka transport provider (requires SlimMessageBus.Host.Kafka package)\n               .WithProviderKafka(cfg =\u003e cfg.BrokerList = \"localhost:9092\");\n\n            // Use Azure Service Bus transport provider\n            //.WithProviderServiceBus(cfg =\u003e { ... }) // requires SlimMessageBus.Host.AzureServiceBus package\n            // Use Azure Event Hub transport provider\n            //.WithProviderEventHub(cfg =\u003e { ... }) // requires SlimMessageBus.Host.AzureEventHub package\n            // Use Redis transport provider\n            //.WithProviderRedis(cfg =\u003e { ... }) // requires SlimMessageBus.Host.Redis package\n            // Use RabbitMQ transport provider\n            //.WithProviderRabbitMQ(cfg =\u003e { ... }) // requires SlimMessageBus.Host.RabbitMQ package\n\n            // Use in-memory transport provider\n            //.WithProviderMemory(cfg =\u003e { ... }) // requires SlimMessageBus.Host.Memory package\n   })\n   // Add other bus transports (as child bus for in memory domain events), if needed\n   //.AddChildBus(\"Bus2\", (builder) =\u003e {  })\n   .AddJsonSerializer() // requires SlimMessageBus.Host.Serialization.SystemTextJson or SlimMessageBus.Host.Serialization.Json package\n   .AddServicesFromAssemblyContaining\u003cOrderCreatedEventConsumer\u003e();\n});\n```\n\nThe configuration can be [modularized](docs/intro.md#modularization-of-configuration) (for modular monoliths).\n\n## 📖 Documentation\n\n- [Introduction](docs/intro.md)\n- Transports:\n  - [Amazon SQS/SNS](docs/provider_amazon_sqs.md)\n  - [Apache Kafka](docs/provider_kafka.md)\n  - [Azure EventHubs](docs/provider_azure_eventhubs.md)\n  - [Azure ServiceBus](docs/provider_azure_servicebus.md)\n  - [Hybrid](docs/provider_hybrid.md)\n  - [MQTT](docs/provider_mqtt.md)\n  - [Memory](docs/provider_memory.md)\n  - [NATS](docs/provider_nats.md)\n  - [RabbitMQ](docs/provider_rabbitmq.md)\n  - [Redis](docs/provider_redis.md)\n  - [SQL](docs/provider_sql.md)\n- Plugins:\n  - [Serialization](docs/serialization.md)\n  - [Transactional Outbox](docs/plugin_outbox.md)\n  - [Validation using FluentValidation](docs/plugin_fluent_validation.md)\n  - [AsyncAPI specification generation](docs/plugin_asyncapi.md)\n  - [Consumer Circuit Breaker](docs/intro.md#health-check-circuit-breaker)\n- [Samples](src/Samples/README.md)\n- [Use Cases](docs/UseCases/)\n\n## 📦 NuGet Packages\n\n| Name                                 | Description                                                                                                         | NuGet                                                                                                                                                                            |\n| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `SlimMessageBus`                     | The core API for SlimMessageBus                                                                                     | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.svg)](https://www.nuget.org/packages/SlimMessageBus)                                                                     |\n| **Transports**                       |                                                                                                                     |                                                                                                                                                                                  |\n| `.Host.AmazonSQS`                    | Transport provider for Amazon SQS / SNS                                                                             | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.AmazonSQS.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.AmazonSQS)                                       |\n| `.Host.AzureEventHub`                | Transport provider for Azure Event Hubs                                                                             | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.AzureEventHub.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.AzureEventHub)                               |\n| `.Host.AzureServiceBus`              | Transport provider for Azure Service Bus                                                                            | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.AzureServiceBus.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.AzureServiceBus)                           |\n| `.Host.Kafka`                        | Transport provider for Apache Kafka                                                                                 | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Kafka.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Kafka)                                               |\n| `.Host.MQTT`                         | Transport provider for MQTT                                                                                         | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.MQTT.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.MQTT)                                                 |\n| `.Host.Memory`                       | Transport provider implementation for in-process (in memory) message passing (no messaging infrastructure required) | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Memory.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Memory)                                             |\n| `.Host.NATS`                         | Transport provider for [NATS](https://nats.io/)                                                                     | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.NATS.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.NATS)                                                 |\n| `.Host.RabbitMQ`                     | Transport provider for RabbitMQ                                                                                     | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.RabbitMQ.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.RabbitMQ)                                         |\n| `.Host.Redis`                        | Transport provider for Redis                                                                                        | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Redis.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Redis)                                               |\n| `.Host.Sql` (pending)                | Transport provider implementation for SQL database message passing                                                  | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Sql.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Sql)                                                   |\n| **Serialization**                    |                                                                                                                     |                                                                                                                                                                                  |\n| `.Host.Serialization.Json`           | Serialization plugin for JSON (Newtonsoft.Json library)                                                             | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Serialization.Json.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Serialization.Json)                     |\n| `.Host.Serialization.SystemTextJson` | Serialization plugin for JSON (System.Text.Json library)                                                            | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Serialization.SystemTextJson.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Serialization.SystemTextJson) |\n| `.Host.Serialization.Avro`           | Serialization plugin for Avro (Apache.Avro library)                                                                 | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Serialization.Avro.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Serialization.Avro)                     |\n| `.Host.Serialization.Hybrid`         | Plugin that delegates serialization to other serializers based on message type                                      | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Serialization.Hybrid.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Serialization.Hybrid)                 |\n| `.Host.Serialization.GoogleProtobuf` | Serialization plugin for Google Protobuf                                                                            | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Serialization.GoogleProtobuf.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Serialization.GoogleProtobuf) |\n| **Plugins**                          |                                                                                                                     |                                                                                                                                                                                  |\n| `.Host.AspNetCore`                   | Integration for ASP.NET Core                                                                                        | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.AspNetCore.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.AspNetCore)                                     |\n| `.Host.Interceptor`                  | Core interface for interceptors                                                                                     | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Interceptor.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Interceptor)                                   |\n| `.Host.FluentValidation`             | Validation for messages based on [FluentValidation](https://www.nuget.org/packages/FluentValidation)                | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.FluentValidation.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.FluentValidation)                         |\n| `.Host.Outbox.Sql`                   | Transactional Outbox using MSSQL                                                                                    | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Outbox.Sql.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql)                                     |\n| `.Host.Outbox.Sql.DbContext`         | Transactional Outbox using MSSQL with EF DataContext integration                                                    | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.Outbox.Sql.DbContext.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql.DbContext)                 |\n| `.Host.AsyncApi`                     | [AsyncAPI](https://www.asyncapi.com/) specification generation via [Saunter](https://github.com/tehmantra/saunter)  | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.AsyncApi.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.AsyncApi)                                         |\n| `.Host.CircuitBreaker.HealthCheck`   | Consumer circuit breaker based on [health checks](docs/intro.md#health-check-circuit-breaker)                       | [![NuGet](https://img.shields.io/nuget/v/SlimMessageBus.Host.CircuitBreaker.HealthCheck.svg)](https://www.nuget.org/packages/SlimMessageBus.Host.CircuitBreaker.HealthCheck)     |\n\nTypically the application layers (domain model, business logic) only need to depend on `SlimMessageBus` which is the facade, and ultimately the application hosting layer (ASP.NET, Console App, Windows Service) will reference and configure the other packages (`SlimMessageBus.Host.*`) which are the messaging transport providers and additional plugins.\n\n## 🎯 Features\n\n- Supports multiple messaging patterns: pub/sub, request-response, queues\n- Compatible with popular brokers: Kafka, RabbitMQ, Azure EventHubs, MQTT, Redis, and more\n- Fluent API for easy configuration\n- Plugin architecture for serialization, validation, outbox patterns and [interceptor pipeline](docs/intro.md#interceptors)\n- Integration with .NET dependency injection\n- Modern async/await support\n- Minimal external dependencies\n- [SourceLink](docs/intro.md#debugging) support\n- Because SlimMessageBus is a facade, chosen messaging transports can be swapped without impacting the overall application architecture.\n\n## 🚧 Contributing\n\nWe welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for details on submitting issues, feature requests, and pull requests.\nSee [here](docs/Maintainers/).\n\n## 💬 Community\n\n- Raise issues, discussions, questions and feature requests [here](https://github.com/zarusz/SlimMessageBus/issues).\n\n## 📜 License\n\nSlimMessageBus is licensed under the [Apache License 2.0](LICENSE).\n\n## 🙌 Credits\n\nSpecial thanks to:\n\n- Our maintainers\n- [Gravity9](https://www.gravity9.com/) for Azure infrastructure support.\n- [Redis Labs](https://redislabs.com/), [CloudKarafka](https://www.cloudkarafka.com/), [HiveMQ](https://www.hivemq.com/), [CloudAMQP](https://www.cloudamqp.com/) for providing infrastructure for testing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzarusz%2Fslimmessagebus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzarusz%2Fslimmessagebus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzarusz%2Fslimmessagebus/lists"}