RabbitMQ.Bus
0.0.6
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RabbitMQ.Bus --version 0.0.6
NuGet\Install-Package RabbitMQ.Bus -Version 0.0.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="RabbitMQ.Bus" Version="0.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RabbitMQ.Bus --version 0.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RabbitMQ.Bus, 0.0.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 RabbitMQ.Bus as a Cake Addin #addin nuget:?package=RabbitMQ.Bus&version=0.0.6 // Install RabbitMQ.Bus as a Cake Tool #tool nuget:?package=RabbitMQ.Bus&version=0.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
采用autofac进行DI的管理 目前仅支持Topic模式
使用方法
在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.ClientProvidedName = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
//关闭网络自动恢复
options.AutomaticRecoveryEnabled = false;
//开启持久化消息
options.Persistence = true;
//开启Autofac支持
options.AddAutofac(services)
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
//true为自动订阅,默认false,则采用之前的订阅方式,注入RabbitMQBusService后使用Subscribe泛型进行订阅
app.UseRabbitMQBus(true);
}
订阅处理方法
[Queue(ExchangeName = "dev.ex", RoutingKey = "send.#")]
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 IRabbitMQBus _rabbit;
public IndexController(IRabbitMQBus rabbit)
{
_rabbit = rabbit ?? throw new ArgumentNullException(nameof(rabbit));
}
[HttpPost]
public async Task<IActionResult> Send()
{
_rabbit.Publish( new { Name = "Hello RabbitMQ" }, routingKey: "send.message",exchangeName: "dev.ex");
//OR
_rabbit.Publish(new Person{ Name = "Hello RabbitMQ" });
}
}
Product | Versions 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection (>= 2.1.1)
- Newtonsoft.Json (>= 11.0.2)
- RabbitMQ.Client (>= 5.1.0)
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 | 1,347 | 11/5/2018 |
1.0.5 | 1,312 | 10/18/2018 |
1.0.4 | 692 | 10/18/2018 |
1.0.3 | 1,091 | 10/18/2018 |
1.0.1 | 862 | 10/14/2018 |
1.0.0 | 1,527 | 9/27/2018 |
0.0.8 | 2,053 | 7/5/2018 |
0.0.7 | 1,134 | 6/28/2018 |
0.0.6 | 905 | 6/27/2018 |
0.0.5 | 1,246 | 6/27/2018 |
0.0.4 | 1,323 | 6/26/2018 |
0.0.3 | 1,247 | 6/24/2018 |
0.0.2 | 1,258 | 6/24/2018 |
0.0.1 | 1,247 | 6/1/2018 |