InMemoryQueue.Client.Grpc 1.0.18

dotnet add package InMemoryQueue.Client.Grpc --version 1.0.18
                    
NuGet\Install-Package InMemoryQueue.Client.Grpc -Version 1.0.18
                    
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="InMemoryQueue.Client.Grpc" Version="1.0.18" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="InMemoryQueue.Client.Grpc" Version="1.0.18" />
                    
Directory.Packages.props
<PackageReference Include="InMemoryQueue.Client.Grpc" />
                    
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 InMemoryQueue.Client.Grpc --version 1.0.18
                    
#r "nuget: InMemoryQueue.Client.Grpc, 1.0.18"
                    
#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.
#:package InMemoryQueue.Client.Grpc@1.0.18
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=InMemoryQueue.Client.Grpc&version=1.0.18
                    
Install as a Cake Addin
#tool nuget:?package=InMemoryQueue.Client.Grpc&version=1.0.18
                    
Install as a Cake Tool

InMemoryQueue

Creates a in memory queue service in .net

Disclaimer: This project is not intended for replacing any queue broker available on the market. Such as Rabbitmq or kafka... If you need something that have persistent messages delivery, this is not for you

How to use it ? (Server)

  • Server using Kestrel:
  • Add package: InMemoryQueue

Program.cs

using MemoryQueue;
using MemoryQueue.Transports.GRPC.Services;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddGrpc();
builder.Services.AddGrpcReflection();

builder.Services.AddSingleton<InMemoryQueueManager>(); //<<---

var app = builder.Build();

// Configure the HTTP request pipeline.
app.MapGrpcService<ConsumerServiceImpl>(); //<<---
app.MapGrpcReflectionService();

app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
app.Run();

appsettings.json

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "GrpcHostedOnKestrel": true,
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://0.0.0.0:5000"
      },
      "Https": {
        "Url": "https://0.0.0.0:5001"
      }
    },
    "EndpointDefaults": {
      "Protocols": "Http2"
    }
  }
}

How to use it ? (Client)

  • Console App
  • Add package: InMemoryQueue.Client.Grpc
using MemoryQueue.Client.Grpc;
using MemoryQueue.Transports.GRPC;

CancellationTokenSource cts = new CancellationTokenSource();
var queueConsumer = new GrpcQueueConsumer("127.0.0.1:5000");
var consumer = queueConsumer.Consume("MyConsoleConsumer", CallBack, cts.Token);
var producer = Task.Run(async () =>
{
    while (!cts.Token.IsCancellationRequested)
    {
        await Task.Delay(TimeSpan.FromSeconds(1));
        try
        {
            await queueConsumer.PublishAsync(new QueueItemRequest()
            {
                Message = "teste"
            });
        }
        catch (Exception)
        {
            //Ignore any exception -- server may not be available
        }
    }
});

//Press any key to exit
Console.ReadKey();
cts.Cancel();
await consumer;


Task<bool> CallBack(QueueItemReply queueItem, CancellationToken arg2)
{
    Console.WriteLine(queueItem);
    return Task.FromResult(true);
}

Running Example:

  1. Clone Repo
  2. Run Visual Studio (Loading solution InMemoryQueue.sln)
  3. Run Examples\Hosts\DirectSocket\GrpcService2
  4. Run Examples\Clients\Winforms.App
  5. At the winforms app click on Start (This will start a background thread to random publish items to the queue)
  6. At the winforms app click on Add to add consumers (this will add consumers to the queue)

Example

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.0.18 438 1/20/2023
1.0.17 376 1/18/2023
1.0.16 353 1/18/2023