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.5 552 6/7/2024
0.2.1-rc.3 3,417 4/27/2024
0.1.1-rc.64 1,394 1/18/2024
0.1.1-rc.62 132 12/18/2023
0.1.1-rc.58 87 12/18/2023
0.1.1-rc.56 83 12/17/2023
0.1.1-rc.54 75 12/17/2023
0.1.1-rc.29 91 12/8/2023
0.1.1-rc.25 179 9/25/2023
0.1.1-rc.23 77 9/25/2023
0.1.1-rc.21 87 9/18/2023
0.1.1-rc.19 72 9/18/2023
0.1.1-rc.17 73 9/18/2023
0.1.1-rc.15 74 9/18/2023
0.1.1-rc.14 79 9/11/2023
0.1.1-rc.12 75 9/11/2023
0.1.1-rc.10 246 8/29/2023
0.1.1-rc.8 85 8/21/2023
0.1.1-rc.6 77 8/21/2023
0.1.1-rc.4 81 8/21/2023
0.1.1-rc.2 78 8/21/2023
0.1.0 1,229 8/10/2023
0.1.0-rc.108 82 8/10/2023
0.1.0-rc.106 83 8/10/2023
0.1.0-rc.104 83 8/10/2023
0.1.0-rc.102 108 7/31/2023
0.1.0-rc.100 160 7/22/2023
0.1.0-rc.94 89 7/10/2023
0.1.0-rc.91 76 7/10/2023
0.1.0-rc.87 88 7/1/2023
0.1.0-rc.86 86 7/1/2023
0.1.0-rc.85 85 7/1/2023
0.1.0-rc.84 83 7/1/2023
0.1.0-rc.83 83 7/1/2023
0.1.0-rc.82 129 6/11/2023
0.1.0-rc.80 84 6/11/2023
0.1.0-rc.72 84 6/10/2023
0.1.0-rc.54 116 5/17/2023