NetPro.RabbitMQ 6.0.3-beta.6

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

// Install NetPro.RabbitMQ as a Cake Tool
#tool nuget:?package=NetPro.RabbitMQ&version=6.0.3-beta.6&prerelease                

NetPro.RabbitMQ使用

使用

NuGet

初始化Rabbit服务(代码方式)
 services.AddRabbitMqClient(new RabbitMqClientOptions
 {
     HostName = "192.168.7.66",
     Port = 5672,
     Password = "guest",
     UserName = "guest",
     VirtualHost= "/",
 })
 .AddProductionExchange("LeonTest", new RabbitMqExchangeOptions
     {
         DeadLetterExchange = "DeadExchange", //不为空,默认不重发
         AutoDelete = false,
         Type = "fanout",
         Durable = true,
         Queues = new List<RabbitMqQueueOptions> { new RabbitMqQueueOptions { AutoDelete = false, Exclusive = false, Durable = true, Name = "myqueue", RoutingKeys = new HashSet<string> { "mini", "yang" } } }
     })
     .AddConsumptionExchange($"{LeonTest}", new RabbitMqExchangeOptions
            {
                DeadLetterExchange = "DeadExchange", //不为空,默认不重发
                AutoDelete = false,
                Type = ExchangeType.Direct,
                Durable = true,
                Queues = new List<RabbitMqQueueOptions> { new RabbitMqQueueOptions { AutoDelete = false, Exclusive = false, Durable = true, Name = $"{myqueue}", RoutingKeys = new HashSet<string> { "myqueue" } } }
            }).AddMessageHandlerSingleton<CustomMessageHandler>("myqueue");

            services.BuildServiceProvider().GetRequiredService<IQueueService>().StartConsuming();;
"RabbitMq": {
	"HostName": "127.0.0.1",
	"Port": "5672",
	"UserName": "guest",
	"Password": "guest"
    },
"RabbitMqExchange": {
	"Type": "direct",
	"Durable": true,
	"AutoDelete": false,
	"DeadLetterExchange": "default.dlx.exchange",
	"RequeueFailedMessages": true,
	"Queues": [
		{
		 "Name": "myqueue",
		 "RoutingKeys": [ "routing.key" ]
		}]
	}

生产消息


namespace MQ.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        private readonly IQueueService _queueService;
        public ValuesController(IQueueService queueService)
        {
            _queueService = queueService;
        }
        // GET api/values
        [HttpGet]
        [Route("Send")]
        public ActionResult<IEnumerable<string>> Send(string mes)
        {
            _queueService.Send(//发送消息
                                @object: $"{mes}",
                                exchangeName: "LeonTest",
                                routingKey: "yang"
                                 );
            return new string[] { "value1", "value2" };
        }
    }
}
 }

消费消息

namespace ReceiveB.Service
{
    //继承IMessageHandler,即可作为消费者消费消息
    public class CustomMessageHandler : IMessageHandler
    {
         private readonly IServiceScopeFactory _serviceScopeFactory;
        readonly ILogger<CustomMessageHandler> _logger;
        public CustomMessageHandler(ILogger<CustomMessageHandler> logger,
          IServiceScopeFactory serviceScopeFactory)
        {
            //由于消费者在BuildServiceProvider()之前就执行导致对象还没注入,所以此处不支持自定义类型的实例注入,只能通过IServiceScopeFactory来获取servcie实例
            _logger = logger;
            _serviceScopeFactory = serviceScopeFactory;
        }

        public void Handle(string message, string routingKey)
        {
            using var scope = _serviceScopeFactory.CreateScope();
            var _redisOptionService = scope.ServiceProvider.GetRequiredService<IRedisOptionService>();

            Console.WriteLine($"正在消费消息");
            _logger.LogInformation("");
        }
    }
}
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. 
.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
6.0.16 183 7/24/2023
6.0.15 417 7/19/2022
6.0.14 449 7/10/2022
6.0.13 405 6/15/2022
6.0.12 398 6/15/2022
6.0.11 425 6/15/2022
6.0.10 418 6/11/2022
6.0.9 425 6/8/2022
6.0.8 424 5/26/2022
6.0.8-beta.3 114 5/24/2022
6.0.8-beta.2 113 5/24/2022
6.0.7 429 5/18/2022
6.0.6 456 4/28/2022
6.0.5 448 3/30/2022
6.0.5-beta.20 121 4/27/2022
6.0.5-beta.19 117 4/25/2022
6.0.5-beta.18 120 4/22/2022
6.0.5-beta.17 125 4/16/2022
6.0.5-beta.16 131 4/8/2022
6.0.5-beta.15 122 4/8/2022
6.0.5-beta.14 132 4/7/2022
6.0.5-beta.13 130 4/7/2022
6.0.5-beta.12 132 4/6/2022
6.0.5-beta.11 123 4/6/2022
6.0.5-beta.10 121 3/31/2022
6.0.5-beta.9 135 3/26/2022
6.0.5-beta.8 135 3/22/2022
6.0.5-beta.7 125 3/21/2022
6.0.5-beta.6 135 3/14/2022
6.0.5-beta.5 127 3/2/2022
6.0.5-beta.4 127 2/22/2022
6.0.5-beta.3 129 2/18/2022
6.0.5-beta.2 123 2/18/2022
6.0.5-beta.1 130 2/16/2022
6.0.4 459 2/10/2022
6.0.3 455 2/9/2022
6.0.3-beta.9 127 2/10/2022
6.0.3-beta.7 137 1/27/2022
6.0.3-beta.6 135 1/19/2022
6.0.3-beta.5 137 1/17/2022
6.0.3-beta.4 136 1/16/2022
6.0.3-beta.3 134 1/14/2022
6.0.3-beta.2 138 1/13/2022
6.0.3-beta.1 154 1/11/2022
6.0.2 310 1/6/2022
6.0.1 897 12/3/2021
3.1.11 341 11/17/2021
3.1.10 434 7/29/2021
3.1.9 345 7/1/2021
3.1.8 412 12/15/2020
3.1.6 508 9/16/2020
3.1.5 444 9/8/2020
3.1.1 493 6/23/2020
3.1.0 530 5/24/2020
1.0.1 504 5/4/2020