NATS.Client.Core 2.2.2

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package NATS.Client.Core --version 2.2.2
NuGet\Install-Package NATS.Client.Core -Version 2.2.2
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="NATS.Client.Core" Version="2.2.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NATS.Client.Core --version 2.2.2
#r "nuget: NATS.Client.Core, 2.2.2"
#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 NATS.Client.Core as a Cake Addin
#addin nuget:?package=NATS.Client.Core&version=2.2.2

// Install NATS.Client.Core as a Cake Tool
#tool nuget:?package=NATS.Client.Core&version=2.2.2

License Apache 2.0 NuGet

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 current .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 Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on NATS.Client.Core:

Package Downloads
NATS.Client.JetStream The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

JetStream support for NATS.Client.

NATS.Client.Services The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Service API support for NATS.Client.

NATS.Client.Hosting The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

ASP.NET Core and Generic Host support for NATS.Client.

NATS.Net The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

NATS client for modern .NET.

NATS.Client.Serializers.Json The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

NATS client generic JSON serializer. Not suitable for native AOT deployments.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.2 379 5/23/2024
2.2.1 14,718 4/17/2024
2.2.0 8,168 4/4/2024
2.1.4 13,851 3/19/2024
2.1.3 3,267 3/12/2024
2.1.2 15,257 2/27/2024
2.1.1 4,364 2/20/2024
2.1.0 7,874 2/10/2024
2.1.0-preview.7 58 2/8/2024
2.1.0-preview.6 81 2/2/2024
2.1.0-preview.5 1,323 1/25/2024
2.1.0-preview.4 53 1/23/2024
2.1.0-preview.3 13,252 1/18/2024
2.1.0-preview.2 1,318 1/12/2024
2.1.0-preview.1 69 1/11/2024
2.0.3 50,843 1/5/2024
2.0.3-preview.1 283 12/22/2023
2.0.2 21,061 12/15/2023
2.0.2-preview.2 76 12/12/2023
2.0.2-preview.1 1,166 12/6/2023
2.0.1 16,678 11/29/2023
2.0.0 1,147 11/23/2023
2.0.0-rc.2 960 11/21/2023
2.0.0-rc.1 329 11/17/2023
2.0.0-beta.3 70 11/16/2023
2.0.0-beta.2 5,564 11/13/2023
2.0.0-beta.1 645 11/7/2023
2.0.0-beta.0 390 11/7/2023
2.0.0-alpha.7 561 10/27/2023
2.0.0-alpha.6 134 10/25/2023
2.0.0-alpha.5 214 10/20/2023
2.0.0-alpha.4 4,984 10/12/2023
2.0.0-alpha.3 309 9/13/2023
2.0.0-alpha.2 94 9/7/2023
2.0.0-alpha.1 95 8/31/2023
2.0.0-alpha.0 839 7/10/2023