Escendit.Orleans.Streaming.RabbitMQ 0.1.0

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

// Install Escendit.Orleans.Streaming.RabbitMQ as a Cake Tool
#tool nuget:?package=Escendit.Orleans.Streaming.RabbitMQ&version=0.1.0

NuGet Package: Escendit.Orleans.Streaming.RabbitMQ

Escendit.Orleans.Streaming.RabbitMQ is a NuGet Package that integrates RabbitMQ with Orleans Streaming Provider.

The Library contains 2 different ways of streaming, first via Stream Protocol, and other via AMQP protocol.

The Library provides named connections to Rabbit MQ, which can be used for low-level integration events.

Installation

To install Escendit.Orleans.Streaming.RabbitMQ, run the following command in the Package Manager Console:

Install-Package Escendit.Orleans.Streaming.RabbitMQ

Usage

To use Escendit.Orleans.Streaming.RabbitMQ first register the stream provider using the AddRabbitMqStreaming method in the Orleans configuration:

SiloBuilder
var builder = new SiloBuilder()
    .AddRabbitMqStreaming("ProviderName");
ClientBuilder
var builder = new ClientBuilder()
    .AddRabbitMqStreaming("ProviderName");

Stream Protocol

To use Escendit.Orleans.Streaming.RabbitMQ with Stream Protocol, first register the stream provider using the AddRabbitMqStreaming method in the Orleans configuration, and then call the WithStream method to specify that the provider should use the Stream Protocol:

SiloBuilder
var hostBuilder = Host
    .CreateDefaultBuilder()
    .UseOrleans(builder =>
    {
        builder
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "cluster-id";
                options.ServiceId = "service-id";
            })
            .AddStreaming()
            .AddRabbitMqStreaming("ProviderName")
            .WithStream(options =>
            {
                options.Endpoints.Add(new RabbitEndpoint { HostName = "localhost", Port = 5552 });
                options.UserName = "guest";
                options.Password = "guest";
                options.VirtualHost = "/";
            });
    });
ClientBuilder
var hostBuilder = Host
    .CreateDefaultBuilder()
    .UseOrleansClient(builder =>
    {
        builder
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "cluster-id";
                options.ServiceId = "service-id";
            })
            .AddStreaming()
            .AddRabbitMqStreaming("ProviderName")
            .WithStream(options =>
            {
                options.Endpoints.Add(new RabbitEndpoint { HostName = "localhost", Port = 5552 });
                options.UserName = "guest";
                options.Password = "guest";
                options.VirtualHost = "/";
            });            
    })

AMQP Protocol

To use Escendit.Orleans.Streaming.RabbitMQ with Stream Protocol, first register the stream provider using the AddRabbitMqStreaming method in the Orleans configuration, and then call the WithQueue method to specify that the provider should use the AMQP Protocol:

SiloBuilder
var hostBuilder = Host
    .CreateDefaultBuilder()
    .UseOrleans(builder =>
    {
        builder
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "cluster-id";
                options.ServiceId = "service-id";
            })
            .AddStreaming()
            .AddRabbitMqStreaming("ProviderName")
            .WithQueue(options =>
            {
                options.Endpoints.Add(new RabbitEndpoint { HostName = "localhost", Port = 5672 });
                options.UserName = "guest";
                options.Password = "guest";
                options.VirtualHost = "/";
            });
    });
ClientBuilder
var hostBuilder = Host
    .CreateDefaultBuilder()
    .UseOrleansClient(builder =>
    {
        builder
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "cluster-id";
                options.ServiceId = "service-id";
            })
            .AddStreaming()
            .AddRabbitMqStreaming("ProviderName")
            .WithQueue(options =>
            {
                options.Endpoints.Add(new RabbitEndpoint { HostName = "localhost", Port = 5672 });
                options.UserName = "guest";
                options.Password = "guest";
                options.VirtualHost = "/";
            });            
    })

Low Level Registration

You can register the Rabbit MQ Classic Client, but the name must not conflict with the Orleans Streaming Provider.

SiloBuilder
var hostBuilder = Host
    .CreateDefaultBuilder()
    .UseOrleans(builder =>
    {
        builder
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "cluster-id";
                options.ServiceId = "service-id";
            })
            .ConfigureServices(services => services
                .AddRabbitMq("ProviderName", options =>
                {
                    options.Endpoints.Add(new RabbitEndpoint { HostName = "localhost", Port = 5672 });
                    options.UserName = "guest";
                    options.Password = "guest";
                    options.VirtualHost = "/";
                })
                .WithConnection());
    });
ClientBuilder
var hostBuilder = Host
    .CreateDefaultBuilder()
    .UseOrleansClient(builder =>
    {
        builder
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "cluster-id";
                options.ServiceId = "service-id";
            })
            .ConfigureServices(services => services
                .AddRabbitMq("ProviderName", options =>
                {
                    options.Endpoints.Add(new RabbitEndpoint { HostName = "localhost", Port = 5672 });
                    options.UserName = "guest";
                    options.Password = "guest";
                    options.VirtualHost = "/";
                })
                .WithConnection());          
    })

Consume

Create a stream:

public class MyGrain : Grain, IMyGrain
{
    private IAsyncStream<T> _stream;
    public override async Task OnActivateAsync()
    {
        var streamProvider = this.GetStreamProvider("ProviderName");
        _stream = _streamProvider.GetStream<int>(this.GetPrimaryKey(), "stream-namespace");
        _stream.SubscribeAsync(ReceiveMessage);
        await base.OnActivateAsync();
    }

    public async Task SendMessage()
    {
        // Send a message
        await _stream.OnNextAsync(42);
    }
    
    public Task ReceiveMessage(Event @event)
    {
        // Receive a message.
    }
}

Create a low-level connection:

public class MyService : GrainService
{
    private readonly IConnection _connection;
    public MyService(string name, IServiceProvider serviceProvider)
    {
        _connection = serviceProvider.GetRequiredServiceByName<IConnection>(name);
    }
}

Contributing

If you'd like to contribute to Escendit.Orleans.Streaming.RabbitMQ, please fork the repository and make changes as you'd like. Pull requests are warmly welcome.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Escendit.Orleans.Streaming.RabbitMQ:

Package Downloads
Escendit.Orleans.Streaming.RabbitMQ.AmqpProtocol

RabbitMQ Orleans AMQP Streaming Provider

Escendit.Orleans.Streaming.RabbitMQ.StreamProtocol

RabbitMQ Orleans Stream Protocol Streaming Provider

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.1-rc.3 58 4/27/2024
0.1.1-rc.64 591 1/18/2024
0.1.1-rc.62 119 12/18/2023
0.1.1-rc.58 76 12/18/2023
0.1.1-rc.56 71 12/17/2023
0.1.1-rc.54 63 12/17/2023
0.1.1-rc.29 79 12/8/2023
0.1.1-rc.25 164 9/25/2023
0.1.1-rc.23 65 9/25/2023
0.1.1-rc.21 73 9/18/2023
0.1.1-rc.19 59 9/18/2023
0.1.1-rc.17 60 9/18/2023
0.1.1-rc.15 60 9/18/2023
0.1.1-rc.14 62 9/11/2023
0.1.1-rc.12 62 9/11/2023
0.1.1-rc.10 232 8/29/2023
0.1.1-rc.8 70 8/21/2023
0.1.1-rc.6 64 8/21/2023
0.1.1-rc.4 68 8/21/2023
0.1.1-rc.2 65 8/21/2023
0.1.0 1,177 8/10/2023
0.1.0-rc.108 69 8/10/2023
0.1.0-rc.106 71 8/10/2023
0.1.0-rc.104 70 8/10/2023
0.1.0-rc.102 94 7/31/2023
0.1.0-rc.100 145 7/22/2023
0.1.0-rc.94 72 7/10/2023
0.1.0-rc.91 62 7/10/2023
0.1.0-rc.87 74 7/1/2023
0.1.0-rc.86 72 7/1/2023
0.1.0-rc.85 71 7/1/2023
0.1.0-rc.84 70 7/1/2023
0.1.0-rc.83 70 7/1/2023
0.1.0-rc.82 114 6/11/2023
0.1.0-rc.80 68 6/11/2023
0.1.0-rc.72 70 6/10/2023
0.1.0-rc.54 103 5/17/2023