Carotte 1.0.0-preview.3
dotnet add package Carotte --version 1.0.0-preview.3
NuGet\Install-Package Carotte -Version 1.0.0-preview.3
<PackageReference Include="Carotte" Version="1.0.0-preview.3" />
<PackageVersion Include="Carotte" Version="1.0.0-preview.3" />
<PackageReference Include="Carotte" />
paket add Carotte --version 1.0.0-preview.3
#r "nuget: Carotte, 1.0.0-preview.3"
#:package Carotte@1.0.0-preview.3
#addin nuget:?package=Carotte&version=1.0.0-preview.3&prerelease
#tool nuget:?package=Carotte&version=1.0.0-preview.3&prerelease
Carotte 🥕
This library is currently under development and is not yet ready for production use. This is a Proof of Concept (PoC) created entirely using Junie, with a focus on writing as little code as possible.
Carotte is a high-level, high-performance RabbitMQ client wrapper for .NET 10, designed for seamless microservices communication with built-in observability, convention-based topologies, resilient error handling, and zero-allocation execution pipelines.
🚀 Key Features
- 🏎️ Optimized for .NET 10 & C# 14: Modern patterns, zero-allocation typed invokers (
IMessageInvoker), and minimal heap footprint on the hot path. - 🔭 Built-in Observability: Native OpenTelemetry integration (Distributed Tracing
ActivitySource& Prometheus/OTLP Metrics). - 🔄 Convention over Configuration: Automatic queue, exchange, and binding topologies (
x.pub.*$\rightarrow$x.sub.*$\rightarrow$q.*). - 🛡️ Resilience & Dead-Letter Handling: Built-in exponential backoff retries, non-transient poison message rejection, and automated Dead-Letter Exchanges/Queues (DLX/DLQ).
- 🧩 Flexible Consumers & Publishers: Strongly-typed
IConsumer<TMessage>(single or multi-message handling) and explicitIPublisher<TMessage>. - 🔌 Extensible Pipelines: Interceptor middlewares for publishers and consumers (Tracing, Metrics, Serialization, Validation).
- 📦 Automatic DI Registration: Assembly scanning with namespace filtering for automatic discovery of handlers.
📦 Installation
Install the core package via NuGet:
dotnet add package Carotte
Complementary Packages
| Package | Description |
|---|---|
Carotte.Documentation |
Automated Markdown, AsyncAPI v3.0 & Mermaid topology generator |
Carotte.TestKit |
In-memory testing utilities and pipeline simulation |
🏁 Quick Start
1. Register Carotte in Dependency Injection
In your Program.cs:
using Carotte;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCarotte(carotte =>
{
// Configure RabbitMQ broker connection
carotte.AddBroker("default", options =>
{
options.Host = "localhost";
options.UserName = "guest";
options.Password = "guest";
options.DefaultPrefetchCount = 10; // Optional: Default is 1 (strict FIFO)
});
// Optional: Prefix queues and exchanges with service name (explicit or automatic from assembly)
carotte.WithServiceName("order-service");
// carotte.WithServiceNameFromEntryAssembly(); // automatically infers from entry assembly
// carotte.WithServiceNameFrom<Program>(); // automatically infers from specified type/assembly
// Scan assembly for IConsumer<T> handlers and [Published] message types
carotte.ScanAssemblies(typeof(Program).Assembly);
// carotte.ScanAssemblyContaining<Program>();
// carotte.ScanNamespaces("MyApp.Consumers");
// Optional: Configure OpenTelemetry OTLP Exporter
carotte.AddOtlpExporter("http://localhost:4317");
});
var app = builder.Build();
app.Run();
2. Define a Message and a Consumer
// Define message contract
public record OrderCreatedEvent(Guid OrderId, string CustomerName, decimal Amount);
// Define consumer (queue is automatically named 'q.order-service.order-consumer')
public class OrderConsumer(ILogger<OrderConsumer> logger) : IConsumer<OrderCreatedEvent>
{
public Task HandleAsync(OrderCreatedEvent message, CancellationToken cancellationToken)
{
logger.LogInformation("Processing order {OrderId} for {Customer}", message.OrderId, message.CustomerName);
return Task.CompletedTask;
}
}
3. Publish Messages
Mark messages with [Published] to enable publishing:
[Published]
public record CreateOrderCommand(Guid OrderId, string CustomerName, decimal Amount);
public class OrderService(IPublisher<CreateOrderCommand> publisher)
{
public async Task CreateOrderAsync(Guid orderId, string customer, decimal amount)
{
await publisher.PublishAsync(new CreateOrderCommand(orderId, customer, amount));
}
}
⚙️ Advanced Topologies & Dead Letters
Customize queues, routing keys, and dead-letter strategies with attributes:
[Queue(
Name = "custom-orders-queue",
Exchange = "orders-exchange",
RoutingKey = "orders.created",
MaxRetryAttempts = 3,
DeadLetterExchange = "x.orders-dlx",
DeadLetterQueue = "q.orders-dlq")]
public class CustomOrderConsumer : IConsumer<OrderCreatedEvent>
{
public Task HandleAsync(OrderCreatedEvent message, CancellationToken cancellationToken)
{
// Handling logic
return Task.CompletedTask;
}
}
📄 License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Configuration.Binder (>= 10.0.11)
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.11)
- OpenTelemetry (>= 1.18.0)
- OpenTelemetry.Api (>= 1.18.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.18.0)
- OpenTelemetry.Extensions.Hosting (>= 1.18.0)
- RabbitMQ.Client (>= 7.2.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Carotte:
| Package | Downloads |
|---|---|
|
Carotte.Documentation
Automated Markdown, AsyncAPI 3.0, and Mermaid topology documentation generator for Carotte microservices. |
|
|
Carotte.TestKit
Testing utilities, in-memory publishers, and consumer pipeline simulation for Carotte microservices. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.3 | 74 | 8/31/2026 |
| 1.0.0-preview.2 | 77 | 8/30/2026 |