FastCSharp.RabbitSubscriber
0.0.1-alpha
See the version list below for details.
dotnet add package FastCSharp.RabbitSubscriber --version 0.0.1-alpha
NuGet\Install-Package FastCSharp.RabbitSubscriber -Version 0.0.1-alpha
<PackageReference Include="FastCSharp.RabbitSubscriber" Version="0.0.1-alpha" />
paket add FastCSharp.RabbitSubscriber --version 0.0.1-alpha
#r "nuget: FastCSharp.RabbitSubscriber, 0.0.1-alpha"
// Install FastCSharp.RabbitSubscriber as a Cake Addin #addin nuget:?package=FastCSharp.RabbitSubscriber&version=0.0.1-alpha&prerelease // Install FastCSharp.RabbitSubscriber as a Cake Tool #tool nuget:?package=FastCSharp.RabbitSubscriber&version=0.0.1-alpha&prerelease
FastCSharp's RabbitMQ Subscriber
RabbitSubscriber provides a simple approach for subscribing to a RabbitMQ queue.
It is a wrapper around the RabbitMQ.Client library.
Usage
All you need to do is create a new subscriber to an existing queue and register a callback.
Program.cs
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using FastCSharp.RabbitSubscriber;
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("rabbitsettings.json", true, true)
.Build();
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
var exchange = new RabbitSubscriberFactory(configuration, loggerFactory);
using var subscriber = exchange.NewSubscriber<Message>("TASK_QUEUE");
subscriber.Register(async (message) =>
{
Console.WriteLine($"Received {message?.Text}");
return await Task.Run<bool>(()=>true);
});
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
public class Message
{
public Message()
{
}
public string? Text { get; set; }
}
rabbitsettings.json config file sample
{
"RabbitSubscriberConfig" :
{
"HostName" : "localhost",
"VirtualHost" : "MyVirtualHost",
"Port" : 5672,
"UserName" : "guest",
"Password" : "guest",
"HeartbeatTimeout" : "00:00:20",
"Queues" :
{
"TASK_QUEUE" :
{
"Name":"test.direct.q",
"PrefecthCount":1,
"PrefecthSize":0
}
}
}
}
Adding a Circuit Breaker
The subscriber can be stopped by calling:
subscriber.UnSubscribe();
This is a useful callback when a circuit breaker is triggered and the OnOpen
or OnBreak
events are fired.
The subscriber can be reset by calling:
subscriber.Reset();
This is a useful callback when a circuit breaker is triggered and the OnReset
event is fired.
Check the FastCSharp.CircuitBreaker package for more information on circuit breakers.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
-
net7.0
- FastCSharp.Common (>= 0.0.0-alpha)
- FastCSharp.Subscriber (>= 0.0.0-alpha)
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 7.0.4)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- RabbitMQ.Client (>= 6.4.0)
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 | |
---|---|---|---|
2.4.0 | 185 | 9/8/2024 | |
2.3.0 | 249 | 5/7/2024 | |
2.2.0 | 397 | 1/5/2024 | |
2.1.0 | 148 | 12/19/2023 | |
2.0.0 | 126 | 12/17/2023 | |
1.0.0 | 192 | 10/20/2023 | |
0.3.0-alpha | 121 | 9/24/2023 | |
0.2.1-alpha | 111 | 9/22/2023 | |
0.2.0-alpha | 121 | 9/22/2023 | |
0.0.1-alpha | 114 | 9/18/2023 | |
0.0.0-alpha | 126 | 4/9/2023 |