Skip to main content
net10.0net8.0

Microsoft Orleans streaming provider backed by AWS SQS

Published
Jun 24, 2026
3mo ago
Total Downloads
421.4K
421,442

Install

dotnet add package Microsoft.Orleans.Streaming.SQS --version 10.2.1
ProductVersions
.NET
net10.0net8.0

README

Microsoft Orleans Streaming for Amazon SQS

Introduction

Microsoft Orleans Streaming for Amazon SQS provides a stream provider implementation for Orleans using Amazon Simple Queue Service (SQS). This allows for publishing and subscribing to streams of events with SQS as the underlying messaging infrastructure.

Getting Started

To use this package, install it via NuGet:

dotnet add package Microsoft.Orleans.Streaming.SQS

Example - Configuring SQS Streaming

using Microsoft.Extensions.Hosting;
using Orleans.Hosting;
using Orleans.Streams;

var builder = Host.CreateApplicationBuilder(args)
    .UseOrleans(siloBuilder =>
    {
        siloBuilder
            .UseLocalhostClustering()
            // Configure SQS as a stream provider
            .AddSqsStreams(
                name: "SQSStreamProvider",
                configureOptions: options =>
                {
                    options.AccessKey = "YOUR_AWS_ACCESS_KEY";
                    options.SecretKey = "YOUR_AWS_SECRET_KEY";
                    options.Region = "us-east-1";
                });
    });

// Run the host
await builder.RunAsync();

Example - Using SQS Streams in a Grain

using System;
using System.Threading;
using System.Threading.Tasks;
using Orleans;
using Orleans.Streams;

// Producer grain
public class ProducerGrain : Grain, IProducerGrain
{
    private IAsyncStream<string> _stream;

    public override Task OnActivateAsync(CancellationToken cancellationToken)
    {
        // Get a reference to a stream
        var streamProvider = GetStreamProvider("SQSStreamProvider");
        _stream = streamProvider.GetStream<string>(Guid.NewGuid(), "MyStreamNamespace");
        
        return base.OnActivateAsync(cancellationToken);
    }

    public async Task SendMessage(string message)
    {
        // Send a message to the stream
        await _stream.OnNextAsync(message);
    }
}

// Consumer grain
public class ConsumerGrain : Grain, IConsumerGrain, IAsyncObserver<string>
{
    private StreamSubscriptionHandle<string> _subscription;

    public override async Task OnActivateAsync(CancellationToken cancellationToken)
    {
        // Get a reference to a stream
        var streamProvider = GetStreamProvider("SQSStreamProvider");
        var stream = streamProvider.GetStream<string>(this.GetPrimaryKey(), "MyStreamNamespace");
        
        // Subscribe to the stream
        _subscription = await stream.SubscribeAsync(this);
        
        await base.OnActivateAsync(cancellationToken);
    }

    public Task OnNextAsync(string item, StreamSequenceToken token = null)
    {
        Console.WriteLine($"Received message: {item}");
        return Task.CompletedTask;
    }

    public Task OnCompletedAsync()
    {
        Console.WriteLine("Stream completed");
        return Task.CompletedTask;
    }

    public Task OnErrorAsync(Exception ex)
    {
        Console.WriteLine($"Stream error: {ex.Message}");
        return Task.CompletedTask;
    }
}

Documentation

For more comprehensive documentation, please refer to:

Feedback & Contributing

Changes from Previous Version

No structural changes between v10.2.1-preview.1 and v10.2.1.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.The published metadata declares 55 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.