RabbitMQ.Bus 0.0.2

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
NuGet\Install-Package RabbitMQ.Bus -Version 0.0.2
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.
dotnet add package RabbitMQ.Bus --version 0.0.2
<PackageReference Include="RabbitMQ.Bus" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RabbitMQ.Bus --version 0.0.2
#r "nuget: RabbitMQ.Bus, 0.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install RabbitMQ.Bus as a Cake Addin
#addin nuget:?package=RabbitMQ.Bus&version=0.0.2

// Install RabbitMQ.Bus as a Cake Tool
#tool nuget:?package=RabbitMQ.Bus&version=0.0.2

使用方法

在asp.net core中

public IServiceProvider ConfigureServices(IServiceCollection services)
{
   services.AddMvc();
    services.AddRabbitMQBus("amqp://guest:guest@192.168.0.252:5672/");
    //OR
    services.AddRabbitMQBus("amqp://guest:guest@192.168.0.252:5672/", options =>
    {
        //关闭网络自动恢复
        options.AutomaticRecoveryEnabled = false;
        //开启持久化消息
        options.Persistence = true;
    });
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, RabbitMQBusService busService)
{
   //订阅
   busService.Subscribe<Person>();
   //OR
   busService.AutoSubscribe();
}

订阅处理方法

[Queue("rabbitmq.bus.dev.test", ExchangeName = "", RoutingKey = "")]
public class Person
{
    public string Name { set; get; }
}
public class PersonHandler : IRabbitMQBusHandler<Person>
{
    public Task Handle(Person message)
    {
        Console.WriteLine($"收到消息:{message.Name}");
        return Task.CompletedTask;
    }
}

发送消息

[Route("api/v1/[controller]")]
public class IndexController : Controller
{
   private readonly RabbitMQBusService _rabbit;
   public IndexController(RabbitMQBusService rabbit)
   {
      _rabbit = rabbit ?? throw new ArgumentNullException(nameof(rabbit));
   }
   [HttpPost]
   public async Task<IActionResult> Send()
   {
      _rabbit.Publish("交换机名","队列名", new { Name = "Hello RabbitMQ" },"路由Key");
      //OR
      _rabbit.Publish(new Person{ Name = "Hello RabbitMQ" });
   }
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RabbitMQ.Bus:

Package Downloads
RabbitMQ.Bus.Autofac

用于在asp.net core mvc中使用aotufac进行RabbitMQ.Bus的注册。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 996 11/5/2018
1.0.5 998 10/18/2018
1.0.4 507 10/18/2018
1.0.3 787 10/18/2018
1.0.1 643 10/14/2018
1.0.0 1,150 9/27/2018
0.0.8 1,563 7/5/2018
0.0.7 829 6/28/2018
0.0.6 682 6/27/2018
0.0.5 898 6/27/2018
0.0.4 890 6/26/2018
0.0.3 994 6/24/2018
0.0.2 1,001 6/24/2018
0.0.1 987 6/1/2018