Chirp 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Chirp --version 1.0.0
                    
NuGet\Install-Package Chirp -Version 1.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="Chirp" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chirp" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Chirp" />
                    
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 Chirp --version 1.0.0
                    
#r "nuget: Chirp, 1.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.
#:package Chirp@1.0.0
                    
#: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=Chirp&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Chirp&version=1.0.0
                    
Install as a Cake Tool

Chirp - Flexible Messaging Library

Chirp Logo

NuGet License: MIT

Chirp is a flexible, provider-agnostic messaging library that simplifies publishing and consuming messages across various message brokers, including RabbitMQ, Kafka, Redis, Azure Service Bus, Amazon SQS, NATS, and Google PubSub.

Features

  • Provider-agnostic API for messaging operations
  • Unified interface for multiple message brokers
  • Simple integration with dependency injection
  • Support for multiple message brokers:
    • RabbitMQ (fully implemented)
    • Kafka (planned)
    • Redis (planned)
    • Azure Service Bus (planned)
    • Amazon SQS (planned)
    • NATS (planned)
    • Google PubSub (planned)
  • Message retries with configurable retry counts
  • Dead letter exchange/queue support for failed messages
  • Clean subscription management with in-memory event tracking

Installation

dotnet add package Chirp

Getting Started

Configuration

Add the necessary configuration to your appsettings.json:

{
  "RMQ": {
    "Host": "localhost",
    "Port": 5672,
    "Username": "guest",
    "Password": "guest",
    "ExchangeName": "chirp_exchange",
    "ExchangeNameDLX": "chirp_dlx_exchange"
  }
}

Setting Up Dependencies

Register the required dependencies in your Program.cs or Startup.cs:

using Chirp.Application.Interfaces;
using Chirp.Domain.Common;
using Chirp.Infrastructure.EventBus;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

// Add Chirp services with RabbitMQ implementation
services.AddChirp(options =>
{
    options.EventBusType = EventBusType.RabbitMQ;
    options.QueueName = "my_service_queue";
    options.RetryCount = 3;
});

Creating Events

Create event classes that inherit from IntegrationEvent:

using Chirp.Domain.Common;

public record OrderCreatedEvent(int OrderId, string CustomerName, decimal Total) : IntegrationEvent;

Creating Event Handlers

Create handlers that implement IIntegrationEventHandler<T>:

using Chirp.Application.Interfaces;

public class OrderCreatedEventHandler : IIntegrationEventHandler<OrderCreatedEvent>
{
    public async Task Handle(OrderCreatedEvent @event)
    {
        // Process the event
        Console.WriteLine($"Order {event.OrderId} created for {event.CustomerName} with total {event.Total}");
        await Task.CompletedTask;
    }
}

Publishing Events

Inject IEventBus and publish events:

public class OrderService
{
    private readonly IEventBus _eventBus;

    public OrderService(IEventBus eventBus)
    {
        _eventBus = eventBus;
    }

    public void CreateOrder(int orderId, string customerName, decimal total)
    {
        // Create and publish the event
        var orderCreatedEvent = new OrderCreatedEvent(orderId, customerName, total);
        _eventBus.Publish(orderCreatedEvent);
    }
}

Subscribing to Events

Subscribe to events in your application startup:

public class Startup
{
    public void Configure(IApplicationBuilder app)
    {
        var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
        
        // Subscribe to events
        eventBus.Subscribe<OrderCreatedEvent, OrderCreatedEventHandler>();
    }
}

Advanced Usage

Using the Event Bus Factory

You can also use the EventBusFactory to create an instance of the event bus:

IEventBus eventBus = EventBusFactory.Create(
    EventBusType.RabbitMQ,
    serviceProvider,
    configuration,
    "my_service_queue",
    retryCount: 5);

Working with Multiple Event Bus Implementations

If your application needs to work with multiple message brokers:

// Configure RabbitMQ
services.AddChirp(options =>
{
    options.EventBusType = EventBusType.RabbitMQ;
    options.QueueName = "rabbitmq_queue";
});

// Add Redis (when implemented)
services.AddChirpRedis(options =>
{
    options.ChannelName = "redis_channel";
});

Supported Message Brokers

Provider Status Configuration Section
RabbitMQ ? Implemented RMQ
Kafka ?? Planned Kafka
Redis ?? Planned Redis
Azure Service Bus ?? Planned AzureServiceBus
Amazon SQS ?? Planned AWS:SQS
NATS ?? Planned NATS
Google PubSub ?? Planned GooglePubSub

Contributing

Contributions are welcome! Feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Created by Andrew Eberle

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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.8 144 7/6/2025
1.0.7 130 7/6/2025
1.0.6 130 7/6/2025
1.0.5 128 7/6/2025
1.0.4 136 7/6/2025
1.0.3 133 7/6/2025
1.0.2 139 7/2/2025
1.0.1 138 7/2/2025
1.0.0 132 7/2/2025