![]() |
VOOZH | about |
dotnet add package cloops.nats --version 1.1.6
NuGet\Install-Package cloops.nats -Version 1.1.6
<PackageReference Include="cloops.nats" Version="1.1.6" />
<PackageVersion Include="cloops.nats" Version="1.1.6" />Directory.Packages.props
<PackageReference Include="cloops.nats" />Project file
paket add cloops.nats --version 1.1.6
#r "nuget: cloops.nats, 1.1.6"
#:package cloops.nats@1.1.6
#addin nuget:?package=cloops.nats&version=1.1.6Install as a Cake Addin
#tool nuget:?package=cloops.nats&version=1.1.6Install as a Cake Tool
π CI
π NuGet
π License: MIT
A modern, annotation-based SDK for building reliable distributed systems with NATS. Define your message consumers with simple attributes and let the framework handle the complexity.
NATS is a powerful messaging system that enables you to build sophisticated, fault-tolerant distributed systems that are location-transparent and globally distributed.
π‘ Learn more: Check out this podcast from nats.fm for insights into NATS architecture.
Modern developers expect annotation-based definitions and dependency injectionβthe same developer experience you get with REST frameworks like ASP.NET Core. This SDK brings that same simplicity to NATS, so you can focus on your business logic instead of boilerplate.
Validate() method are automatically validated before processing. Invalid messages are never sent to your handlersπ― Building microservices? Check out our microservices-focused SDK built on top of
cloops.natsand makes building microservices a breeze!
Add the cloops.nats package to your .csproj file:
<PackageReference Include="cloops.nats" Version="*" />
Run dotnet restore to install the package.
π‘ Tip: For Connection Loops standard messages and subjects, you may also need
cloops.nats.schema.
Broadcast Pattern (Kubernetes/Docker)
Ensure each pod/instance receives all messages by using runtime placeholders in the queue group name:
/// <summary>
/// Broadcast: Each pod gets a unique queue group, so all pods receive all messages
/// Supported placeholders: {POD_NAME}, {HOSTNAME}, {MACHINE_NAME}, {ENV:VAR_NAME}
/// </summary>
[NatsConsumer("test.broadcast", QueueGroupName = "pod-{POD_NAME}")]
public Task<NatsAck> BroadcastHandler(NatsMsg<string> msg, CancellationToken ct = default)
{
Console.WriteLine($"[Pod {Environment.GetEnvironmentVariable("POD_NAME")}] Received: {msg.Data}");
return Task.FromResult(new NatsAck(true));
}
Load Balancing Pattern
Distribute messages across multiple instances using the same queue group:
[NatsConsumer("test.lb", QueueGroupName = "workers")]
public async Task<NatsAck> HandleMessage(NatsMsg<string> msg, CancellationToken ct = default)
{
Console.WriteLine($"Instance received: {msg.Data}");
await Task.Delay(100, ct).ConfigureAwait(false); // Simulate work
return new NatsAck(true);
}
Runtime Placeholders
The SDK resolves placeholders dynamically:
{POD_NAME} β POD_NAME env var, falls back to HOSTNAME or machine name{HOSTNAME} β HOSTNAME env var, falls back to machine name{MACHINE_NAME} β Machine name{ENV:VAR_NAME} β Any environment variable (e.g., {ENV:MY_CUSTOM_VAR})π Note:
QueueGroupNameis optional. If omitted, an empty string is used, which still enables load balancing. JetStream subscriptions are always load-balanced (no broadcast support).
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on cloops.nats:
| Package | Downloads |
|---|---|
|
cloops.microservices
Opinionated SDK to effortlessly build lean highly performant cloud native microservices |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.6 | 6,076 | 12/14/2025 |
| 1.1.5 | 200 | 12/14/2025 |
| 1.1.4 | 199 | 12/14/2025 |
| 1.1.3 | 156 | 12/14/2025 |
| 1.1.2 | 152 | 12/14/2025 |
| 1.1.1 | 161 | 12/13/2025 |
| 1.0.42 | 358 | 11/17/2025 |
| 1.0.41 | 271 | 11/9/2025 |
| 1.0.40 | 201 | 11/9/2025 |
| 1.0.39 | 153 | 11/8/2025 |
| 1.0.38 | 172 | 11/8/2025 |
| 1.0.37 | 170 | 11/8/2025 |
| 1.0.36 | 215 | 10/12/2025 |
| 1.0.35 | 169 | 10/11/2025 |
| 1.0.34 | 214 | 9/28/2025 |
| 1.0.33 | 225 | 9/2/2025 |
| 1.0.32 | 221 | 9/2/2025 |
| 1.0.31 | 220 | 9/1/2025 |
| 1.0.30 | 216 | 9/1/2025 |
| 1.0.29 | 219 | 9/1/2025 |