Asa.RabbitMq 1.0.12

There is a newer version of this package available.
See the version list below for details.
dotnet add package Asa.RabbitMq --version 1.0.12
                    
NuGet\Install-Package Asa.RabbitMq -Version 1.0.12
                    
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="Asa.RabbitMq" Version="1.0.12" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Asa.RabbitMq" Version="1.0.12" />
                    
Directory.Packages.props
<PackageReference Include="Asa.RabbitMq" />
                    
Project file
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 Asa.RabbitMq --version 1.0.12
                    
#r "nuget: Asa.RabbitMq, 1.0.12"
                    
#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.
#addin nuget:?package=Asa.RabbitMq&version=1.0.12
                    
Install as a Cake Addin
#tool nuget:?package=Asa.RabbitMq&version=1.0.12
                    
Install as a Cake Tool

Asa.RabbitMq

依赖注入配置

StartUp中添加

services.AddRabbitMqConfigureServices();

builder.Services.AddRabbitMqConfigureServices();

或者在 Autofac 中添加

builder.Host.ConfigureContainer<ContainerBuilder>(containerBuilder =>
{
  containerBuilder.AddAutofacRabbitMqConfigureServices();
  // 注册其他依赖项
  containerBuilder.RegisterType<A>().As<IA>();
});

** 两者只能存在一个!!!**

appsettings.json 配置

ConnectionStrings 节点中添加

"RabbitMQConnection": "amqp://user:password@ip:port/",
"MongodbMqRecordConnection": "mongodb://user:password@ip:port/"

启动 rabbitmq 和日志记录。

消费者

public class A : IConsumer
{
   public void Configure(IConsumerConfiguration consumerConfiguration)
   {
       consumerConfiguration
           .WithExchangeName("test.exchangename")
           .WithRoutingKey("test.routingkey")
           .WithQueueName("test.queuename")
           .WithExchangeType(ExchangeTypeEnum.Topic)
           .WithPrefetchCount(20)
           .WithRetryCount(3);
   }

   public async Task InvokeAsync(Message message)
   {
       await Task.Delay(100);
       //todo
   }
   // 或者
   public void Invoke(Message message)
   {
       //todo
   }
}

生产者

// 使用依赖注入
private readonly IPublisher _publisher;

// 方法中
await _publisher.PublishAsync(
new Message() { Content = "测试消息 },
option =>
   option
   .WithExchangeName(("test.exchangename")
   .WithRoutingKey("test.routingkey")
   .WithQueueName("test.queuename")
   .WithExchangeType(ExchangeTypeEnum.Topic));

延迟消息说明

  • 生产者: [WithDeliverTime] 添加延迟的秒数
  • 消费者: [WithIsDelayQueue] 设置为 true

延迟消息用的插件rabbitmq_delayed_message_exchange,注意版本。

查看生产和消费记录

IRabbitMqRecord

  • GetPublishPageListAsync: 获取推送记录
  • GetReceivedPageListAsync: 获取接收记录
  • RePublishAsync: 重新推送消息
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.13 229 4/16/2025
1.0.12 195 4/14/2025
1.0.11 159 3/30/2025
1.0.10 144 3/27/2025
1.0.9 106 1/15/2025
1.0.8 114 11/28/2024
1.0.7 125 11/1/2024
1.0.6 116 11/1/2024
1.0.5 110 11/1/2024
1.0.4 119 10/21/2024
1.0.3 149 9/19/2024
1.0.2 145 8/30/2024
1.0.1 119 8/30/2024
1.0.0 109 8/30/2024