FastCSharp.RabbitSubscriber 0.2.0-alpha

This package has been deprecated as it has critical bugs.
This is a prerelease version of FastCSharp.RabbitSubscriber.
There is a newer version of this package available.
See the version list below for details.
dotnet add package FastCSharp.RabbitSubscriber --version 0.2.0-alpha
                    
NuGet\Install-Package FastCSharp.RabbitSubscriber -Version 0.2.0-alpha
                    
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="FastCSharp.RabbitSubscriber" Version="0.2.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FastCSharp.RabbitSubscriber" Version="0.2.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="FastCSharp.RabbitSubscriber" />
                    
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 FastCSharp.RabbitSubscriber --version 0.2.0-alpha
                    
#r "nuget: FastCSharp.RabbitSubscriber, 0.2.0-alpha"
                    
#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=FastCSharp.RabbitSubscriber&version=0.2.0-alpha&prerelease
                    
Install FastCSharp.RabbitSubscriber as a Cake Addin
#tool nuget:?package=FastCSharp.RabbitSubscriber&version=0.2.0-alpha&prerelease
                    
Install FastCSharp.RabbitSubscriber as a Cake Tool

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 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.  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. 
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
2.4.0 387 7 months ago
2.3.0 420 5/7/2024
2.2.0 461 1/5/2024
2.1.0 160 12/19/2023
2.0.0 140 12/17/2023
1.0.0 205 10/20/2023
0.3.0-alpha 127 9/24/2023
0.2.1-alpha 119 9/22/2023
0.2.0-alpha 130 9/22/2023 0.2.0-alpha is deprecated because it has critical bugs.
0.0.1-alpha 121 9/18/2023
0.0.0-alpha 138 4/9/2023