Zyx.MemoryMQ 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Zyx.MemoryMQ --version 1.0.3                
NuGet\Install-Package Zyx.MemoryMQ -Version 1.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="Zyx.MemoryMQ" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zyx.MemoryMQ --version 1.0.3                
#r "nuget: Zyx.MemoryMQ, 1.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.
// Install Zyx.MemoryMQ as a Cake Addin
#addin nuget:?package=Zyx.MemoryMQ&version=1.0.3

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

用法

  • 首先在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 was computed.  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 was computed.  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 (1)

Showing the top 1 popular GitHub repositories that depend on Zyx.MemoryMQ:

Repository Stars
hzy-6/hzy-admin
前后端分离权限管理系统基架! 数据权限、按钮权限、动态菜单、动态任务调度、动态WebApi、定时标记 [Scheduled("0/5 * * * * ?")] 、代码生成
Version Downloads Last updated
1.0.7 3,114 1/21/2024
1.0.6 2,341 2/16/2023
1.0.5 248 2/16/2023
1.0.4 522 11/14/2022
1.0.3 804 7/15/2022
1.0.2 424 7/11/2022
1.0.1 446 7/8/2022
1.0.0 455 7/7/2022