{"id":28259498,"url":"https://github.com/pavlo-0/qsmessaging","last_synced_at":"2025-07-17T02:09:05.709Z","repository":{"id":261877742,"uuid":"885605128","full_name":"Pavlo-0/QsMessaging","owner":"Pavlo-0","description":"QsMessaging (Quick \u0026 Simple Messaging) is a .NET 8 library that wraps RabbitMQ, providing a fast and straightforward way to implement messaging between services.","archived":false,"fork":false,"pushed_at":"2024-12-25T00:23:51.000Z","size":234,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-15T18:01:05.216Z","etag":null,"topics":["message","messaging","microservice","net","rabbitmq"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pavlo-0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-08T23:25:00.000Z","updated_at":"2024-12-25T00:22:34.000Z","dependencies_parsed_at":"2024-11-09T00:28:23.675Z","dependency_job_id":"2605e819-9963-421d-ad4f-16246670bda6","html_url":"https://github.com/Pavlo-0/QsMessaging","commit_stats":null,"previous_names":["pavlo-0/qsmessaging"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/Pavlo-0/QsMessaging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pavlo-0%2FQsMessaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pavlo-0%2FQsMessaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pavlo-0%2FQsMessaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pavlo-0%2FQsMessaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pavlo-0","download_url":"https://codeload.github.com/Pavlo-0/QsMessaging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pavlo-0%2FQsMessaging/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265560029,"owners_count":23788116,"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":["message","messaging","microservice","net","rabbitmq"],"created_at":"2025-05-20T03:12:15.498Z","updated_at":"2025-07-17T02:09:05.669Z","avatar_url":"https://github.com/Pavlo-0.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QsMessaging\n\n**QsMessaging** is a .NET 8 library designed for sending and receiving messages between services or components of your application using **RabbitMQ**. It supports horizontal scalability, allowing multiple instances of the same service to handle messages efficiently.  \nAvailable on NuGet for seamless integration:  \n[![NuGet](https://img.shields.io/nuget/v/QsMessaging.svg)](https://www.nuget.org/packages/QsMessaging/)  \n\nA simple, scalable messaging solution for distributed systems.\n\n## Installation\n\nInstall the package using the following command:\n\n```bash\ndotnet add package QsMessaging\n```\n\n## Registering the Library\n\nRegistering the library is simple. Add the following two lines of code to your `Program.cs`:\n\n```csharp\n// Add QsMessaging (use the default configuration)...\nbuilder.Services.AddQsMessaging(options =\u003e { });\n\n...\nawait host.UseQsMessaging();\n```\n\n### Default Configuration\n\n**RabbitMQ**  \n- Host: `localhost`  \n- UserName: `guest`  \n- Password: `guest`  \n- Port: `5672`\n\n## Usage\n\n### Sending Messages\n\n#### Contract\n\nDefine a message contract:\n\n```csharp\npublic class RegularMessageContract\n{\n    public required string MyTextMessage { get; set; } \n}\n```\n\n#### Sending a Message\n\nInject `IQsMessaging` into your class:\n\n```csharp\npublic YourClass(IQsMessaging qsMessaging) {}\n```\n\nThen, use it to send a message:\n\n```csharp\nawait qsMessaging.SendMessageAsync(new RegularMessageContract { MyTextMessage = \"My message.\" });\n```\n\n### Handling Messages\n\nTo handle the message, create a handler:\n\n```csharp\npublic class RegularMessageContractHandler : IQsMessageHandler\u003cRegularMessageContract\u003e\n{\n    public Task\u003cbool\u003e Consumer(RegularMessageContract contractModel)\n    {\n        // Process the message here\n        return Task.FromResult(true);\n    }\n}\n```\n\n---\n\n### Request/Response Pattern\n\nYou can also use the **Request/Response** pattern to send a request and await a response. This is useful when you need to communicate between services and expect a response.\n\n#### Request/Response Contract\n\nDefine the request and response contracts:\n\n```csharp\npublic class MyRequestContract\n{\n    public required string RequestMessage { get; set; }\n}\n\npublic class MyResponseContract\n{\n    public required string ResponseMessage { get; set; }\n}\n```\n\n#### Sending a Request and Receiving a Response\n\nTo send a request and await a response, use the `RequestResponse\u003cTRequest, TResponse\u003e`:\n\n```csharp\npublic class MyService\n{\n    private readonly IQsMessaging _qsMessaging;\n\n    public MyService(IQsMessaging qsMessaging)\n    {\n        _qsMessaging = qsMessaging;\n    }\n\n    public async Task\u003cMyResponseContract\u003e SendRequestAsync(MyRequestContract request)\n    {\n        var response = await _qsMessaging.SendRequestResponseAsync\u003cMyRequestContract, MyResponseContract\u003e(request);\n        return response;\n    }\n}\n```\n\n#### Handling Requests\n\nTo handle requests, implement the `IQsRequestResponseHandler\u003cTRequest, TResponse\u003e` interface:\n\n```csharp\npublic class MyRequestHandler : IQsRequestResponseHandler\u003cMyRequestContract, MyResponseContract\u003e\n{\n    public Task\u003cMyResponseContract\u003e Handle(MyRequestContract request)\n    {\n        // Process the request and create a response\n        return Task.FromResult(new MyResponseContract { ResponseMessage = \"Response to: \" + request.RequestMessage });\n    }\n}\n```\n\n---\n\n**That's all, folks!**\n\n## Documentation\n\nFor detailed documentation, visit the [QsMessaging Wiki](https://github.com/Pavlo-0/QsMessaging/wiki).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpavlo-0%2Fqsmessaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpavlo-0%2Fqsmessaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpavlo-0%2Fqsmessaging/lists"}