MyStack.DistributedMessage4RabbitMQ
2.0.3
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package MyStack.DistributedMessage4RabbitMQ --version 2.0.3
NuGet\Install-Package MyStack.DistributedMessage4RabbitMQ -Version 2.0.3
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="MyStack.DistributedMessage4RabbitMQ" Version="2.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyStack.DistributedMessage4RabbitMQ" Version="2.0.3" />
<PackageReference Include="MyStack.DistributedMessage4RabbitMQ" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MyStack.DistributedMessage4RabbitMQ --version 2.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MyStack.DistributedMessage4RabbitMQ, 2.0.3"
#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.
#:package MyStack.DistributedMessage4RabbitMQ@2.0.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MyStack.DistributedMessage4RabbitMQ&version=2.0.3
#tool nuget:?package=MyStack.DistributedMessage4RabbitMQ&version=2.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MyStack.DistributedMessage4RabbitMQ
An open-source lightweight message bus library (RabbitMQ) that supports publish/subscribe and RPC.
Getting Started
Add Service Support
services.AddDistributedMessage4RabbitMQ(configure =>
{
configure.HostName = "localhost";
configure.VirtualHost = "/";
configure.Port = 5672;
configure.UserName = "admin";
configure.Password = "admin";
configure.QueueOptions.Name = "MyStack";
configure.ExchangeOptions.Name = "MyStack";
configure.ExchangeOptions.ExchangeType = "topic";
configure.RPCTimeout = 2000;
},
Assembly.GetExecutingAssembly());
Event Subscription
Define Event
public class HelloMessage : IDistributedEvent
{
public string Message { get; set; }
}
or
[ExchangeDeclare("Hello")]
[QueueDeclare("Hello")]
[QueueBind("HelloMessage")]
public class HelloMessage : DistributedEventBase
{
public string Message { get; set; } = default!;
}
Subscribe to Event
public class HelloMessageHandler : IDistributedEventHandler<HelloMessage>
{
public async Task HandleAsync(HelloMessage message, CancellationToken cancellationToken)
{
Console.WriteLine("Hello");
await Task.CompletedTask;
}
}
Publish Event
await messageBus.PublishAsync(new HelloMessage() { Message = "Hello" });
or
var hello = new HelloMessage()
{
Message = "Hello World"
};
hello.Metadata.Add("key1", "value");
messageBus.PublishAsync(hello);
Event Wrapper Subscription
Define Wrapped Data
public class WrappedData
{
public string Message { get; set; }
}
Subscribe to Event
public class DistributedEventWrapperHandler : IDistributedEventHandler<DistributedEventWrapper<WrappedData>>
{
public async Task HandleAsync(DistributedEventWrapper<WrappedData> eventData, CancellationToken cancellationToken = default)
{
await Task.CompletedTask;
Console.WriteLine("DistributedEventWrapper");
}
}
Publish Event
await messageBus.PublishAsync(new WrappedData());
3、RPC Request
Define Request
public class Ping : IRpcRequest<Pong>
{
public string SendBy { get; set; }
}
Define Response
public class Pong
{
public string ReplyBy { get; set; }
}
Subscribe to Request
public class PingHandler : IRpcRequestHandler<Ping, Pong>
{
public Task<Pong> HandleAsync(Ping message, CancellationToken cancellationToken = default)
{
Console.WriteLine("Ping");
return Task.FromResult(new Pong() { ReplyBy = "B" });
}
}
Send Request
var pongMessage = messageBus.SendAsync(ping);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.CSharp (>= 4.5.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.0)
- Newtonsoft.Json (>= 13.0.3)
- RabbitMQ.Client (>= 6.7.0)
-
net7.0
- Microsoft.CSharp (>= 4.5.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.3)
- RabbitMQ.Client (>= 6.7.0)
-
net8.0
- Microsoft.CSharp (>= 4.5.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
- RabbitMQ.Client (>= 6.7.0)
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 |
|---|