Zyx.MemoryMQ 1.0.7

dotnet add package Zyx.MemoryMQ --version 1.0.7
NuGet\Install-Package Zyx.MemoryMQ -Version 1.0.7
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="Zyx.MemoryMQ" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zyx.MemoryMQ --version 1.0.7
#r "nuget: Zyx.MemoryMQ, 1.0.7"
#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 Zyx.MemoryMQ as a Cake Addin
#addin nuget:?package=Zyx.MemoryMQ&version=1.0.7

// Install Zyx.MemoryMQ as a Cake Tool
#tool nuget:?package=Zyx.MemoryMQ&version=1.0.7

用法

  • 首先在Services上配置 AddMemoryMQ()
  • 然后在中间件中使用 UseMemoryMQ()
  • 在要接受处理消息的地方 继承IBus<> 接口
  • 在要用到发布消息的地方 先将 IProducer 注入到构造函数中 使用 PublishAsync() 方法发布到消息队列中 消息队列根据 IBus<> 的 topic 进行消息分发(使用多线程同时处理) 发布和接受类型不一致时会提示错误
builder.Services.AddMemoryMQ();
app.UseMemoryMQ();
// 支持构造函数注入
// 当要订阅多个topic时 使用Subscribe特性
public class TestBus : IBus<Test>
{
  public string topic => "123/456";

  private readonly ILogger<TestBus> logger;

  public TestBus(ILogger<TestBus> logger)
  {
    this.logger = logger;
  }

  [Subscribe("123")]
  public Task HandlerAsync(Test data)
  {
    logger.LogInformation("我是TestBus:  " + data.Name);
    return Task.CompletedTask;
  }
}

public class Test
{
  public string Name { get; set; }
}
// 构造函数注入 IProducer 对象
await producer.PublishAsync("123/456",new Test(){Name = name});
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Zyx.MemoryMQ:

Package Downloads
Lofty.Framework.Core

Core 基础组件

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 1,271 1/21/2024
1.0.6 1,719 2/16/2023
1.0.5 218 2/16/2023
1.0.4 495 11/14/2022
1.0.3 756 7/15/2022
1.0.2 396 7/11/2022
1.0.1 416 7/8/2022
1.0.0 412 7/7/2022