InPoint 1.0.1

dotnet add package InPoint --version 1.0.1                
NuGet\Install-Package InPoint -Version 1.0.1                
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="InPoint" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add InPoint --version 1.0.1                
#r "nuget: InPoint, 1.0.1"                
#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 InPoint as a Cake Addin
#addin nuget:?package=InPoint&version=1.0.1

// Install InPoint as a Cake Tool
#tool nuget:?package=InPoint&version=1.0.1                

InPoint - Distributed Messaging Architecture

NuGet Library: Simplifying Messaging Providers in .NET

NuGet Downloads NuGet Version
dotnet add package InPoint --version 1.0.0

PubSub

Introduction

In today's microservices architecture, messaging systems play a crucial role in ensuring seamless communication between services. However, managing multiple messaging providers can be a daunting task. This article addresses a common challenge developers face when integrating various messaging systems in .NET applications and provides a clear solution to streamline this process using the InPoint NuGet library.

The Problem

When working with multiple messaging providers like RabbitMQ, Event Hub, Service Bus, and Event Grid, developers often run into configuration issues, especially when the required providers are not specified in the configuration file. This oversight can lead to runtime errors, making it challenging to maintain and extend your application.

To avoid such pitfalls, it’s essential to ensure that your application is configured correctly to recognize and utilize the specified messaging providers.

The Solution: InPoint NuGet Library

To effectively manage different messaging providers, we can create a modular setup in .NET that allows for easy configuration and integration of various messaging systems. The InPoint NuGet library provides a straightforward way to achieve this, allowing you to register multiple messaging providers easily.

Libraries to Install

To implement this solution, you will need to install the following libraries:

  • dotnet add package RabbitMQ.Client
  • dotnet add package Microsoft.Azure.EventHubs
  • dotnet add package Microsoft.Azure.ServiceBus
  • dotnet add package Microsoft.Azure.EventGrid
JSON Configuration

Here's an example of the appsettings.json file that outlines the configuration for multiple messaging providers:

{
  "MessagingProvider": [ "RabbitMQ", "EventHub", "ServiceBus", "EventGrid" ],
  "RabbitMQ": {
    "Host": "localhost",
    "UserName": "guest",
    "Password": "guest"
  },
  "EventHub": {
    "ConnectionString": "YourEventHubConnectionString",
    "EventHubName": "YourEventHubName"
  },
  "ServiceBus": {
    "ConnectionString": "YourServiceBusConnectionString",
    "QueueName": "YourQueueName"
  },
  "EventGrid": {
    "TopicEndpoint": "https://yourtopic.westeurope-1.eventgrid.azure.net/api/events",
    "SasKey": "YourSasKey"
  }
}
Using the InPoint Library in Your Application
Step 1: Register the InPoint Library

In your Program.cs file, you can register the InPoint messaging services with the following line:

builder.Services.AddInPointMessaging(builder.Configuration);

This will configure your application to utilize the specified messaging providers.

Step 2: Implement Messaging in Your Controller

Here’s how to implement a controller that uses the messaging service to publish messages:

[ApiController]
[Route("api/[controller]")]
public class MessageController : ControllerBase
{
    private readonly InPointPublisherFactory _publisherFactory;
    private readonly IConfiguration _configuration;

    public MessageController(InPointPublisherFactory publisherFactory, IConfiguration configuration)
    {
        _publisherFactory = publisherFactory;
        _configuration = configuration;
    }

    [HttpPost("publish")]
    public async Task<IActionResult> PublishMessage([FromBody] string message)
    {
        var providers = _configuration.GetSection("MessagingProvider").Get<string[]>();
        var selectedProvider = providers.First(); // Choose the provider logic here

        var publisher = _publisherFactory.GetPublisher(selectedProvider);
        await publisher.Publish(message);

        return Ok("Message published successfully!");
    }
}
Step 3: Implement a Notification Service

You can also create a service that utilizes the messaging system to send notifications:

public class NotificationService
{
    private readonly InPointPublisherFactory _publisherFactory;
    private readonly IConfiguration _configuration;

    public NotificationService(InPointPublisherFactory publisherFactory, IConfiguration configuration)
    {
        _publisherFactory = publisherFactory;
        _configuration = configuration;
    }

    public async Task SendNotification(string message)
    {
        var providers = _configuration.GetSection("MessagingProvider").Get<string[]>();
        var selectedProvider = providers.First(); // Choose the provider logic here

        var publisher = _publisherFactory.GetPublisher(selectedProvider);
        await publisher.Publish(message);
    }
}
Additional Resources
License

License: MIT
Copyright (c) 2024 Joever Monceda

Linkedin: Joever Monceda
Medium: Joever Monceda
Twitter @_EthanHunt07
Facebook: Ethan Hunt

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.

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.1 115 10/20/2024
1.0.0 113 10/20/2024