QsMessaging-develop 1.0.139

dotnet add package QsMessaging-develop --version 1.0.139                
NuGet\Install-Package QsMessaging-develop -Version 1.0.139                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="QsMessaging-develop" Version="1.0.139" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QsMessaging-develop --version 1.0.139                
#r "nuget: QsMessaging-develop, 1.0.139"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install QsMessaging-develop as a Cake Addin
#addin nuget:?package=QsMessaging-develop&version=1.0.139

// Install QsMessaging-develop as a Cake Tool
#tool nuget:?package=QsMessaging-develop&version=1.0.139                

QsMessaging

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.
Available on NuGet for seamless integration:
NuGet

A simple, scalable messaging solution for distributed systems.

Installation

Install the package using the following command:

dotnet add package QsMessaging

Registering the Library

Registering the library is simple. Add the following two lines of code to your Program.cs:

// Add QsMessaging (use the default configuration)...
builder.Services.AddQsMessaging(options => { });

...
await host.UseQsMessaging();

Default Configuration

RabbitMQ

  • Host: localhost
  • UserName: guest
  • Password: guest
  • Port: 5672

Usage

Sending Messages

Contract

Define a message contract:

public class RegularMessageContract
{
    public required string MyTextMessage { get; set; } 
}
Sending a Message

Inject IQsMessaging into your class:

public YourClass(IQsMessaging qsMessaging) {}

Then, use it to send a message:

await qsMessaging.SendMessageAsync(new RegularMessageContract { MyTextMessage = "My message." });

Handling Messages

To handle the message, create a handler:

public class RegularMessageContractHandler : IQsMessageHandler<RegularMessageContract>
{
    public Task<bool> Consumer(RegularMessageContract contractModel)
    {
        // Process the message here
        return Task.FromResult(true);
    }
}

Request/Response Pattern

You 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.

Request/Response Contract

Define the request and response contracts:

public class MyRequestContract
{
    public required string RequestMessage { get; set; }
}

public class MyResponseContract
{
    public required string ResponseMessage { get; set; }
}
Sending a Request and Receiving a Response

To send a request and await a response, use the RequestResponse<TRequest, TResponse>:

public class MyService
{
    private readonly IQsMessaging _qsMessaging;

    public MyService(IQsMessaging qsMessaging)
    {
        _qsMessaging = qsMessaging;
    }

    public async Task<MyResponseContract> SendRequestAsync(MyRequestContract request)
    {
        var response = await _qsMessaging.SendRequestResponseAsync<MyRequestContract, MyResponseContract>(request);
        return response;
    }
}
Handling Requests

To handle requests, implement the IQsRequestResponseHandler<TRequest, TResponse> interface:

public class MyRequestHandler : IQsRequestResponseHandler<MyRequestContract, MyResponseContract>
{
    public Task<MyResponseContract> Handle(MyRequestContract request)
    {
        // Process the request and create a response
        return Task.FromResult(new MyResponseContract { ResponseMessage = "Response to: " + request.RequestMessage });
    }
}

That's all, folks!

Documentation

For detailed documentation, visit the QsMessaging Wiki.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.139 90 3 months ago
1.0.138-pr 79 3 months ago
1.0.136 88 3 months ago
1.0.135-pr 70 3 months ago
1.0.134 91 4 months ago
1.0.133 97 4 months ago
1.0.131 94 4 months ago
1.0.130 92 4 months ago
1.0.126 90 4 months ago
1.0.125 85 4 months ago
1.0.121 95 4 months ago
1.0.120 89 4 months ago
1.0.119 91 4 months ago
1.0.112 98 4 months ago
1.0.110 80 4 months ago
1.0.109-pr 67 4 months ago
1.0.106 87 4 months ago
1.0.105 93 4 months ago
1.0.104 92 4 months ago
1.0.103 94 4 months ago
1.0.102 86 4 months ago
1.0.94 95 4 months ago
1.0.93-pr 72 4 months ago
1.0.92 89 4 months ago
1.0.91-pr 72 4 months ago
1.0.90 87 4 months ago
1.0.89 88 4 months ago
1.0.87 89 4 months ago
1.0.86-pr 66 4 months ago
1.0.85 86 4 months ago
1.0.84 89 4 months ago
1.0.83-pr 68 4 months ago
1.0.82 89 4 months ago
1.0.81 95 4 months ago
1.0.80 94 4 months ago
1.0.77 90 4 months ago
1.0.76-pr 85 4 months ago
1.0.75-pr 77 4 months ago
1.0.72 86 4 months ago
1.0.70 90 4 months ago
1.0.69 98 4 months ago