ProSol.Messaging 3.0.0

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

// Install ProSol.Messaging as a Cake Tool
#tool nuget:?package=ProSol.Messaging&version=3.0.0                

ProSol.Messaging

Implements a message broker with ability to build a pipeline of listeners.

API

The project contains an API for the Observer pattern: IPublisher, ISubscriber, and PipelinePublisher.

  • The IPublisher interface is aimed to provide a layer of absctraction to the client.
  • The ISubscriber interface decalres a subscription contract with chained calls support via NextDelegate.
    • NextDelegate: is a mandatory delegate to trigger if current subscriber wants to bypass a message to next subscriber.
  • PipelinePublisher: a ready-to-use implementation for chained subscriptions.

Demo

Let's see how works in a console app, by making a publisher for strings, which addresses the message to the StringListener, but there is a StringLimitListener between them.

So, the StringLimitListener will drop the message longer than "Please" string:

using ProSol.Messaging;

var maxLength = "Please".Length + 1;

var broker = new MessageBroker<string>();
// Set up a chain.
broker.Subscribe(new StringLimitListener(maxLength));
broker.Subscribe(new StringListener());

// Push some messages.
broker.Publish("Please");
broker.Publish("STOP");
broker.Publish("The planet");
// OUTPUT:
// Please
// STOP

// Clean up.
broker.Complete();
public class StringListener : ISubscriber<string>
{
    public void OnCompleted() { }

    public void OnNext(string message, NextDelegate next)
    {
        Console.WriteLine(message);

        if (message != "STOP")
        {
            next();
        }
    }
}
public class StringLimitListener(int limit) : ISubscriber<string>
{
    private readonly int limit = limit;

    public void OnCompleted() { }

    public void OnNext(string message, NextDelegate next)
    {
        if (message.Length < limit)
        {
            next();
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ProSol.Messaging:

Package Downloads
ProSol.Html.TagsProvider

TagsProvider is a tool for extracting HTML tags from a string, in event-driven way. Helps to extract text, structured data, from a specific site.

ProSol.WebScrap

A HTML parser, for extracting the text from a web pages, with CSS selectors.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 486 12/8/2023
4.0.0-rc.9.0 86 12/7/2023
4.0.0-rc.8.0 72 12/7/2023
4.0.0-rc.7.4 78 12/5/2023
4.0.0-rc.7.3 69 12/5/2023
4.0.0-rc.7.2 76 12/5/2023
4.0.0-rc.7.1 78 12/5/2023
4.0.0-rc.7.0 76 12/5/2023
4.0.0-rc.6.0 89 12/2/2023
4.0.0-rc.5.1 80 11/30/2023
4.0.0-rc.5.0 77 11/30/2023
4.0.0-rc.3.0 80 11/24/2023
4.0.0-rc.2 79 11/24/2023
4.0.0-rc.1 82 11/24/2023
3.0.1 178 11/24/2023
3.0.0 168 11/22/2023
3.0.0-rc.0.2 77 11/21/2023
3.0.0-rc.0.1 73 11/20/2023
2.0.0 144 11/19/2023
1.0.0 126 11/16/2023