PhoenixToolkits.MessageQueue.Nats
2.3.0
dotnet add package PhoenixToolkits.MessageQueue.Nats --version 2.3.0
NuGet\Install-Package PhoenixToolkits.MessageQueue.Nats -Version 2.3.0
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="PhoenixToolkits.MessageQueue.Nats" Version="2.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PhoenixToolkits.MessageQueue.Nats --version 2.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PhoenixToolkits.MessageQueue.Nats, 2.3.0"
#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 PhoenixToolkits.MessageQueue.Nats as a Cake Addin #addin nuget:?package=PhoenixToolkits.MessageQueue.Nats&version=2.3.0 // Install PhoenixToolkits.MessageQueue.Nats as a Cake Tool #tool nuget:?package=PhoenixToolkits.MessageQueue.Nats&version=2.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PhoenixToolkits.MessageQueue
PhoenixToolkits.MessageQueue 是為了抽象化訊息傳遞的傳送、接收處理而開發的函式庫。
如何使用套件
安裝 PhoenixToolkits.Message Nuget Package
.NET Core CLI
dotnet add package PhoenixToolkits.MessageQueue
再來,安裝對應實作的套件,實作套件有Direct、InProcess、NATS、MongoDB、RabbitMQ
Examples
Dependency Injection
builder.Services
.AddMessageQueue();
加入MessageQueue System的設定
builder.Services
.AddMessageQueue()
.AddDirectMessageQueue(config => config
.AddProcessor<ProcessorType>("subject1")
.AddHandler<HandlerType>("subject2")
.AddReplyHandler<HandlerType2>("subject3"))
.AddDirectGlobPatternExchange("*");
發送訊息
var messageSender = serviceProvider.GetRequiredService<IMessageSender>();
var request = new SendMessageType
{
...
};
await messageSender.PublishAsync(
"sudject1",
request.ToByteArray(),
cancellationToken).ConfigureAwait(false);
// or
var responseData = await messageSender.RequestAsync(
"sudject1",
request.ToByteArray(),
cancellationToken).ConfigureAwait(false);
var response = ReceiveType.Parser.ParseFrom(responseData.Span);
// or
await messageSender.SendAsync(
"sudject1",
request.ToByteArray(),
cancellationToken).ConfigureAwait(false);
接收訊息
internal class ProcessorType : IMessageProcessor
{
public async ValueTask<ReadOnlyMemory<byte>> HandleAsync(ReadOnlyMemory<byte> data, CancellationToken cancellationToken = default)
{
var request = SendMessageType.Parser.ParseFrom(data.Span);
...
return response.ToByteArray();
}
}
internal class HandlerType : IMessageHandler
{
public async ValueTask HandleAsync(ReadOnlyMemory<byte> data, CancellationToken cancellationToken = default)
{
var request = SendMessageType.Parser.ParseFrom(data.Span);
...
}
}
License
Product | Versions 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 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- NATS.Client.Core (>= 2.5.4)
- NATS.Client.JetStream (>= 2.5.4)
- PhoenixToolkits.AwaitHelpers (>= 0.0.4)
- PhoenixToolkits.MessageQueue (>= 2.3.0)
- System.Interactive.Async (>= 6.0.1)
-
net9.0
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- NATS.Client.Core (>= 2.5.4)
- NATS.Client.JetStream (>= 2.5.4)
- PhoenixToolkits.AwaitHelpers (>= 0.0.4)
- PhoenixToolkits.MessageQueue (>= 2.3.0)
- System.Interactive.Async (>= 6.0.1)
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 |
---|---|---|
2.3.0 | 68 | 11/17/2024 |
2.2.0 | 1,810 | 4/11/2024 |
2.1.2 | 456 | 1/26/2024 |
2.1.1 | 965 | 1/19/2024 |
2.1.0 | 102 | 1/19/2024 |
2.0.2 | 118 | 1/19/2024 |
2.0.1 | 171 | 1/10/2024 |
2.0.0 | 153 | 1/5/2024 |
1.9.12-beta | 116 | 1/3/2024 |
1.9.11-beta | 115 | 12/26/2023 |
1.9.10-beta | 113 | 12/25/2023 |
1.9.9-beta | 110 | 12/22/2023 |
1.9.8-alpha | 107 | 12/19/2023 |
1.9.7-alpha | 100 | 12/19/2023 |
1.9.6-alpha | 116 | 12/19/2023 |
1.9.5-alpha | 81 | 12/19/2023 |
1.9.4-alpha | 75 | 12/18/2023 |
1.9.3-alpha | 98 | 12/18/2023 |
1.9.2-alpha | 101 | 12/18/2023 |
1.9.1-alpha | 106 | 12/18/2023 |
1.9.0-alpha | 93 | 12/12/2023 |
1.0.12-alpha | 133 | 11/28/2023 |
1.0.11-alpha | 108 | 11/28/2023 |
1.0.10-alpha | 111 | 11/27/2023 |
1.0.9-alpha | 127 | 11/23/2023 |
1.0.8-alpha | 101 | 11/22/2023 |
1.0.7-alpha | 99 | 11/20/2023 |
1.0.6 | 621 | 10/31/2023 |
1.0.4 | 151 | 10/30/2023 |
1.0.3 | 324 | 9/11/2023 |
1.0.2 | 156 | 9/11/2023 |
1.0.0 | 247 | 9/9/2023 |