NATS.Net
2.3.1
Prefix Reserved
See the version list below for details.
dotnet add package NATS.Net --version 2.3.1
NuGet\Install-Package NATS.Net -Version 2.3.1
<PackageReference Include="NATS.Net" Version="2.3.1" />
paket add NATS.Net --version 2.3.1
#r "nuget: NATS.Net, 2.3.1"
// Install NATS.Net as a Cake Addin #addin nuget:?package=NATS.Net&version=2.3.1 // Install NATS.Net as a Cake Tool #tool nuget:?package=NATS.Net&version=2.3.1
NATS .NET
NATS .NET is a client library designed to connect to the NATS messaging server, fully supporting all NATS features. It integrates seamlessly with modern .NET asynchronous interfaces such as async enumerables and channels, and leverages advanced .NET memory, buffer and IO features.
Check out NATS .NET client library documentation for guides and examples.
What is NATS?
NATS is a high-performance, secure, distributed messaging system. It's a connective technology tailored for modern distributed systems, facilitating efficient addressing, discovery, and message exchange. It supports dynamic service and stream processing across various locations and devices, enhancing mobility, security, and independence from traditional constraints such as DNS.
Head over to NATS documentation for more information.
Quick Start
Basic messaging:
// NATS core M:N messaging example
await using var nats = new NatsConnection();
// Subscribe on one terminal
await foreach (var msg in nats.SubscribeAsync<string>(subject: "foo"))
{
Console.WriteLine($"Received: {msg.Data}");
}
// Start publishing to the same subject on a second terminal
await nats.PublishAsync(subject: "foo", data: "Hello, World!");
Persistance with JetStream:
await using var nats = new NatsConnection();
var js = new NatsJSContext(nats);
// Create a stream to store the messages
await js.CreateStreamAsync(new StreamConfig(name: "orders", subjects: new[] { "orders.*" }));
// Publish a message to the stream. The message will be stored in the stream
// because the published subject matches one of the the stream's subjects.
var ack = await js.PublishAsync(subject: "orders.new", data: "order 1");
ack.EnsureSuccess();
// Create a consumer on a stream to receive the messages
var consumer = await js.CreateOrUpdateConsumerAsync("orders", new ConsumerConfig("order_processor"));
await foreach (var jsMsg in consumer.ConsumeAsync<string>())
{
Console.WriteLine($"Processed: {jsMsg.Data}");
await jsMsg.AckAsync();
}
See more details, including how to download and start NATS server and JetStream in our documentation.
Additionally check out NATS by example - An evolving collection of runnable, cross-client reference examples for NATS.
NATS .NET Goals
- Only support Async I/O (async/await)
- Target .NET Standard 2.0, 2.1, and .NET LTS releases (currently .NET 6.0 & .NET 8.0)
Packages
- NATS.Net: Meta package that includes all other packages (except serialization)
- NATS.Client.Core: Core NATS
- NATS.Client.JetStream: JetStream
- NATS.Client.KeyValueStore: Key/Value Store
- NATS.Client.ObjectStore: Object Store
- NATS.Client.Services: Services
- NATS.Extensions.Microsoft.DependencyInjection: extension to configure DI container
- NATS.Client.Serializers.Json: JSON serializer for ad-hoc types
Contributing
- Run
dotnet format
at root directory of project in order to clear warnings that can be auto-formatted - Run
dotnet build
at root directory and make sure there are no errors or warnings
Find us on slack.nats.io dotnet channel
Please also check out the Contributor Guide and Code of Conduct.
Attribution
This library is based on the excellent work in Cysharp/AlterNats
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- NATS.Client.Core (>= 2.3.1)
- NATS.Client.Hosting (>= 2.3.1)
- NATS.Client.JetStream (>= 2.3.1)
- NATS.Client.KeyValueStore (>= 2.3.1)
- NATS.Client.ObjectStore (>= 2.3.1)
- NATS.Client.Services (>= 2.3.1)
-
.NETStandard 2.1
- NATS.Client.Core (>= 2.3.1)
- NATS.Client.Hosting (>= 2.3.1)
- NATS.Client.JetStream (>= 2.3.1)
- NATS.Client.KeyValueStore (>= 2.3.1)
- NATS.Client.ObjectStore (>= 2.3.1)
- NATS.Client.Services (>= 2.3.1)
-
net6.0
- NATS.Client.Core (>= 2.3.1)
- NATS.Client.Hosting (>= 2.3.1)
- NATS.Client.JetStream (>= 2.3.1)
- NATS.Client.KeyValueStore (>= 2.3.1)
- NATS.Client.ObjectStore (>= 2.3.1)
- NATS.Client.Services (>= 2.3.1)
-
net8.0
- NATS.Client.Core (>= 2.3.1)
- NATS.Client.Hosting (>= 2.3.1)
- NATS.Client.JetStream (>= 2.3.1)
- NATS.Client.KeyValueStore (>= 2.3.1)
- NATS.Client.ObjectStore (>= 2.3.1)
- NATS.Client.Services (>= 2.3.1)
NuGet packages (14)
Showing the top 5 NuGet packages that depend on NATS.Net:
Package | Downloads |
---|---|
NATS.Extensions.Microsoft.DependencyInjection
ASP.NET Core and Generic Host support for NATS.Net. |
|
Codecabinet.sni.Common.Implementation
Package Description |
|
Neon.SignalR
SignalR helpers and utilities. Includes NATS backplane and a smart load balancer. |
|
Aspire.Hosting.Nats
NATS support for .NET Aspire. |
|
Aspire.NATS.Net
A NATS client that integrates with Aspire, including health checks and logging. |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on NATS.Net:
Repository | Stars |
---|---|
dotnet/aspire
Tools, templates, and packages to accelerate building observable, production-ready apps
|
|
zarusz/SlimMessageBus
Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
|
|
dotnet/dotnet
Home of .NET's Virtual Monolithic Repository which includes all the code needed to build the .NET SDK from source
|
Version | Downloads | Last updated |
---|---|---|
2.5.3 | 978 | 11/5/2024 |
2.5.2 | 5,475 | 10/22/2024 |
2.5.1 | 8,349 | 10/17/2024 |
2.5.0 | 7,363 | 10/9/2024 |
2.5.0-preview.2 | 54 | 10/8/2024 |
2.5.0-preview.1 | 99 | 10/1/2024 |
2.4.0 | 10,690 | 9/17/2024 |
2.4.0-preview.3 | 69 | 9/11/2024 |
2.4.0-preview.2 | 92 | 8/23/2024 |
2.4.0-preview.1 | 1,043 | 8/5/2024 |
2.3.3 | 44,951 | 8/2/2024 |
2.3.3-preview.4 | 160 | 7/26/2024 |
2.3.3-preview.3 | 108 | 7/25/2024 |
2.3.3-preview.2 | 55 | 7/24/2024 |
2.3.3-preview.1 | 153 | 7/18/2024 |
2.3.2 | 25,811 | 7/10/2024 |
2.3.1 | 2,205 | 7/9/2024 |
2.3.1-preview.2 | 62 | 7/8/2024 |
2.3.1-preview.1 | 64 | 7/6/2024 |
2.3.0 | 17,279 | 7/3/2024 |
2.3.0-preview.1 | 114 | 6/24/2024 |
2.2.3 | 21,429 | 6/11/2024 |
2.2.2 | 14,502 | 5/23/2024 |
2.2.1 | 62,326 | 4/17/2024 |
2.2.0 | 13,892 | 4/4/2024 |
2.1.4 | 16,095 | 3/19/2024 |
2.1.3 | 4,996 | 3/12/2024 |
2.1.2 | 23,772 | 2/27/2024 |
2.1.1 | 4,276 | 2/20/2024 |
2.1.0 | 14,233 | 2/10/2024 |
2.1.0-preview.7 | 85 | 2/8/2024 |
2.1.0-preview.6 | 89 | 2/2/2024 |
2.1.0-preview.5 | 1,338 | 1/25/2024 |
2.1.0-preview.4 | 69 | 1/23/2024 |
2.1.0-preview.3 | 163 | 1/18/2024 |
2.1.0-preview.2 | 210 | 1/12/2024 |
2.1.0-preview.1 | 73 | 1/11/2024 |
2.0.3 | 63,192 | 1/5/2024 |
2.0.3-preview.1 | 103 | 12/22/2023 |
2.0.2 | 2,776 | 12/15/2023 |
2.0.2-preview.2 | 78 | 12/12/2023 |
2.0.2-preview.1 | 738 | 12/6/2023 |
2.0.1 | 16,607 | 11/29/2023 |
2.0.0 | 922 | 11/23/2023 |
2.0.0-rc.2 | 82 | 11/21/2023 |
2.0.0-rc.1 | 108 | 11/17/2023 |