{"id":31946430,"url":"https://github.com/stariongroup/mercurio","last_synced_at":"2025-10-14T11:16:27.276Z","repository":{"id":293628562,"uuid":"978140770","full_name":"STARIONGROUP/Mercurio","owner":"STARIONGROUP","description":"A library to make RabbitMQ integration in .NET microservices seamless","archived":false,"fork":false,"pushed_at":"2025-10-09T08:08:12.000Z","size":257,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"development","last_synced_at":"2025-10-11T01:06:20.977Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/STARIONGROUP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-05T14:29:45.000Z","updated_at":"2025-10-09T08:01:57.000Z","dependencies_parsed_at":"2025-05-16T10:25:30.084Z","dependency_job_id":"1d65db48-6b32-4e2b-b467-5850c0614826","html_url":"https://github.com/STARIONGROUP/Mercurio","commit_stats":null,"previous_names":["stariongroup/mercurio"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/STARIONGROUP/Mercurio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STARIONGROUP%2FMercurio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STARIONGROUP%2FMercurio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STARIONGROUP%2FMercurio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STARIONGROUP%2FMercurio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/STARIONGROUP","download_url":"https://codeload.github.com/STARIONGROUP/Mercurio/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STARIONGROUP%2FMercurio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019103,"owners_count":26086513,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-14T11:16:22.488Z","updated_at":"2025-10-14T11:16:27.271Z","avatar_url":"https://github.com/STARIONGROUP.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![mercurio](https://raw.githubusercontent.com/STARIONGROUP/Mercurio/master/mercurio-logo-strapline.png)\n# Mercurio\nA library to make RabbitMQ integration in .NET microservices seamless\n\n## Introduction\nMercurio provides RabbitMQ integration with common implementation of Messaging Client. This common implementation of messaging client reduce the need of code duplication on microservices implementation that requires to interacts with RabbitMQ.  \nIt also eases the setup of ConnectionFactory and also to register multiple ConnectionFactory setup, using the _IRabbitMqConnectionProvider_.\n\nMercurio follows RabbitMQ best practices by encouraging connection reuse and channel pooling per named connection. \nInstead of creating new connections for every operation—which is inefficient and discouraged by RabbitMQ—it provides a shared, \nthread-safe mechanism to lease and reuse channels from a limited pool tied to a single registered connection.\nThis improves performance, resource management, and aligns with RabbitMQ's recommendations for production-grade messaging systems.\n\nSee [channel reuse and connection management](https://github.com/STARIONGROUP/Mercurio/wiki/channel) for more details on the implementation.\n\n## Examples\n### Dependency Injection Registration\n```csharp\nvar serviceCollection = new ServiceCollection();\n\nserviceCollection.AddRabbitMqConnectionProvider()\n    .WithRabbitMqConnectionFactoryAsync(\"Primary\", _ =\u003e\n    {\n        var connectionFactory = new ConnectionFactory()\n        {\n            HostName = \"localhost\",\n            Port =  5432\n        };\n\n        return Task.FromResult(connectionFactory);\n    })\n    .WithRabbitMqConnectionFactory(\"Secondary\", _ =\u003e\n    {\n        var connectionFactory = new ConnectionFactory()\n        {\n            HostName = \"localhost\",\n            Port =  5433\n        };\n\n        return connectionFactory;\n    })\n    .WithSerialization();\n\nvar serviceProvider = serviceCollection.BuildServiceProvider();\nvar connectionProvider = serviceProvider.GetRequiredService\u003cIRabbitMqConnectionProvider\u003e();\nvar primaryConnection = await  connectionProvider.GetConnectionAsync(\"Primary\");\n```\n\n### 📦 Message Serialization\n\nMercurio uses a flexible and extensible serialization system that supports multiple formats and allows format-specific resolution at runtime.\n\nBy default, Mercurio registers **System.Text.Json**-based serializers and deserializers. However, you can register custom implementations or support additional formats like **MessagePack**.\n\nSerialization is configured using `.WithSerialization()` in your service registration:\n\n```csharp\nservices\n    .AddRabbitMqConnectionProvider()\n    .WithSerialization(builder =\u003e builder\n        .UseDefaultJson() // Registers JsonMessageSerializerService that uses System.Text.Json as default serializer\n        .UseMessagePack\u003cYourMessagePackSerializer\u003e(asDefault: false)); // Optional additional format\n```\n\nUnder the hood, serialization is format-aware:\n\n* Each format (e.g., `Json`, `MessagePack`) is keyed by `SupportedSerializationFormat` and is transported in the 'content type' header.\n* A central `SerializationProviderService` handles resolution of serializers and deserializers.\n* The **default format** (usually `Json`) is mapped to the special key `Unspecified`.\n\nThe following interfaces drive the system:\n\n* `IMessageSerializerService` – used to serialize outgoing messages.\n* `IMessageDeserializerService` – used to deserialize incoming messages.\n* `ISerializationProviderService` – allows resolving serializers and deserializers for a given format.\n\nAll registered services are added via `IServiceCollection` using Microsoft.Extensions.DependencyInjection’s [keyed services](https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-usage#keyed-service-registration).\n\n#### 🔧 Default Behavior\n\nIf `.WithSerialization()` is called without configuration, Mercurio will:\n\n* Register `JsonMessageSerializerService` for both serializer and deserializer interfaces.\n* Use `SupportedSerializationFormat.Json` as the default.\n* Register a fallback mapping under `SupportedSerializationFormat.Unspecified`.\n\n#### 🔄 Format Resolution\n\nSerialization and deserialization for a given format can be resolved at runtime via:\n\n```csharp\nvar serializer = serializationProvider.ResolveSerializer(SupportedSerializationFormat.Json);\nvar deserializer = serializationProvider.ResolveDeserializer(SupportedSerializationFormat.MessagePack);\n```\n\n### MessageClientService\nA base implementation of a _MessageClientService_ is available. It defines base behavior to push and listen after messages on queue and exchange.  \nFollowing example expects to have a connection registered, the service registered as _IMessageClientBaseService_ into the service collection and will use Direct Exchange.\n\n#### Push Message\n```csharp\nvar messageClientService = serviceProvider.GetRequiredService\u003cIMessageClientBaseService\u003e();\nvar exchangeConfiguration = new DirectExchangeConfiguration(\"DirectQueue\", \"AnExchange\", \"SomeRouting\");\nawait messageClientService.PushAsync(\"RegisteredConnection\",\"A message to be sent\",exchangeConfiguration);\n```\n\n#### Listen After Message\n```csharp\nvar messageClientService = serviceProvider.GetRequiredService\u003cIMessageClientBaseService\u003e();\nvar exchangeConfiguration = new DirectExchangeConfiguration(\"DirectQueue\", \"AnExchange\", \"SomeRouting\");\nvar messageObservable = await messageClientService.ListenAsync\u003cstring\u003e(\"RegisteredConnection\", exchangeConfiguration);\nmessageObservable.Subscribe(message =\u003e Console.WriteLine(message));\n```\n\n## Integration Tests\nBefore running any integration tests, it is required to have a running instance of RabbitMQ.  \nPlease use this following command to run it :\n```sh\ndocker run -d --name mercurio -p 15672:15672 -p 5672:5672 rabbitmq:4-management \n```\n\n## Code Quality\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=code_smells)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=ncloc)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=security_rating)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=STARIONGROUP_Mercurio\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=STARIONGROUP_Mercurio)\n\n## Nuget\nThe Mercurio library is released as NuGet package and available from [nuget.org](https://www.nuget.org/packages?q=mercurio).  \n![NuGet Badge](https://img.shields.io/nuget/v/Mercurio)\n\n## Software Bill of Materials (SBOM)\n\nAs part of our commitment to security and transparency, this project includes a Software Bill of Materials (SBOM) in the associated NuGet packages. The SBOM provides a detailed inventory of the components and dependencies included in the package, allowing you to track and verify the software components, their licenses, and versions.\n\n**Why SBOM?**\n\n- **Improved Transparency**: Gain insight into the open-source and third-party components included in this package.\n- **Security Assurance**: By providing an SBOM, we enable users to more easily track vulnerabilities associated with the included components.\n- **Compliance**: SBOMs help ensure compliance with licensing requirements and make it easier to audit the project's dependencies.\n\nYou can find the SBOM in the NuGet package itself, which is automatically generated and embedded during the build process.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstariongroup%2Fmercurio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstariongroup%2Fmercurio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstariongroup%2Fmercurio/lists"}