NATS.Client.JetStream
2.0.0-alpha.2
Prefix Reserved
See the version list below for details.
dotnet add package NATS.Client.JetStream --version 2.0.0-alpha.2
NuGet\Install-Package NATS.Client.JetStream -Version 2.0.0-alpha.2
<PackageReference Include="NATS.Client.JetStream" Version="2.0.0-alpha.2" />
paket add NATS.Client.JetStream --version 2.0.0-alpha.2
#r "nuget: NATS.Client.JetStream, 2.0.0-alpha.2"
// Install NATS.Client.JetStream as a Cake Addin #addin nuget:?package=NATS.Client.JetStream&version=2.0.0-alpha.2&prerelease // Install NATS.Client.JetStream as a Cake Tool #tool nuget:?package=NATS.Client.JetStream&version=2.0.0-alpha.2&prerelease
NATS.NET V2
Preview
The NATS.NET V2 client is in preview and not recommended for production use. Codebase is still under heavy development and currently we only have implementations for core NATS features.
Please test and provide feedback by visiting our Slack channel.
NATS.NET V2 Goals
- Only support Async I/O
- Target latest .NET LTS Release (currently
net6.0
)
Packages
- NATS.Client.Core: core NATS
- NATS.Client.Hosting: extension to configure DI container
- NATS.Client.JetStream: JetStream not yet implemented
Basic Usage
Download the latest nats-server
for your platform and run it without any arguments. nats-server
will listen
on its default TCP port 4222.
Given that we have a plain class Bar
, we can publish and subscribe to our nats-server
sending
and receiving Bar
objects:
public record Bar
{
public int Id { get; set; }
public string Name { get; set; }
}
Subscribe to all bar
related subjects:
await using var nats = new NatsConnection(options);
await using sub = await nats.SubscribeAsync<Bar>("bar.>");
await foreach (var msg in sub.Msgs.ReadAllAsync())
{
Console.WriteLine($"Received {msg.Subject}: {msg.Data}\n");
}
Publish Bar
objects to related bar
subjects:
await using var nats = new NatsConnection();
for (int i = 0; i < 10; i++)
{
Console.WriteLine($" Publishing {i}...");
await nats.PublishAsync<Bar>($"bar.baz.{i}", new Bar { Id = i, Name = "Baz" });
}
You should also hook your logger to NatsConnection
to make sure all is working as expected or
to get help diagnosing any issues you might have:
var options = NatsOpts.Default with { LoggerFactory = new MinimumConsoleLoggerFactory(LogLevel.Error) };
await using var nats = new NatsConnection(options);
Contributing
- Run
dotnet format
at root directory of project in order to clear warnings that can be auto-formatted
Attribution
This library is based on the excellent work in Cysharp/AlterNats
Product | Versions 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 was computed. 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. |
-
net6.0
- NATS.Client.Core (>= 2.0.0-alpha.2)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on NATS.Client.JetStream:
Package | Downloads |
---|---|
NATS.Client.KeyValueStore
JetStream Key/Value Store support for NATS.Client. |
|
NATS.Client.ObjectStore
JetStream Object Store support for NATS.Client. |
|
NATS.Net
NATS client for modern .NET |
|
PhoenixToolkits.MessageQueue.Nats
Package Description |
|
Core.ServiceMesh
.NET nats based services mesh and streams |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.5.3 | 0 | 11/5/2024 |
2.5.2 | 4,891 | 10/22/2024 |
2.5.1 | 6,628 | 10/17/2024 |
2.5.0 | 8,218 | 10/9/2024 |
2.5.0-preview.2 | 49 | 10/8/2024 |
2.5.0-preview.1 | 99 | 10/1/2024 |
2.4.0 | 10,066 | 9/17/2024 |
2.4.0-preview.3 | 70 | 9/11/2024 |
2.4.0-preview.2 | 95 | 8/23/2024 |
2.4.0-preview.1 | 1,001 | 8/5/2024 |
2.3.3 | 53,694 | 8/2/2024 |
2.3.3-preview.4 | 174 | 7/26/2024 |
2.3.3-preview.3 | 103 | 7/25/2024 |
2.3.3-preview.2 | 58 | 7/24/2024 |
2.3.3-preview.1 | 163 | 7/18/2024 |
2.3.2 | 33,081 | 7/10/2024 |
2.3.1 | 3,758 | 7/9/2024 |
2.3.1-preview.2 | 64 | 7/8/2024 |
2.3.1-preview.1 | 67 | 7/6/2024 |
2.3.0 | 17,696 | 7/3/2024 |
2.3.0-preview.1 | 130 | 6/24/2024 |
2.2.3 | 39,780 | 6/11/2024 |
2.2.2 | 16,696 | 5/23/2024 |
2.2.1 | 89,737 | 4/17/2024 |
2.2.0 | 16,523 | 4/4/2024 |
2.1.4 | 18,924 | 3/19/2024 |
2.1.3 | 5,355 | 3/12/2024 |
2.1.2 | 24,285 | 2/27/2024 |
2.1.1 | 6,252 | 2/20/2024 |
2.1.0 | 14,636 | 2/10/2024 |
2.1.0-preview.7 | 78 | 2/8/2024 |
2.1.0-preview.6 | 91 | 2/2/2024 |
2.1.0-preview.5 | 1,326 | 1/25/2024 |
2.1.0-preview.4 | 60 | 1/23/2024 |
2.1.0-preview.3 | 13,445 | 1/18/2024 |
2.1.0-preview.2 | 353 | 1/12/2024 |
2.1.0-preview.1 | 67 | 1/11/2024 |
2.0.3 | 67,925 | 1/5/2024 |
2.0.3-preview.1 | 420 | 12/22/2023 |
2.0.2 | 21,870 | 12/15/2023 |
2.0.2-preview.2 | 82 | 12/12/2023 |
2.0.2-preview.1 | 1,165 | 12/6/2023 |
2.0.1 | 16,959 | 11/29/2023 |
2.0.0 | 1,168 | 11/23/2023 |
2.0.0-rc.2 | 811 | 11/21/2023 |
2.0.0-rc.1 | 114 | 11/17/2023 |
2.0.0-beta.3 | 72 | 11/16/2023 |
2.0.0-beta.2 | 5,559 | 11/13/2023 |
2.0.0-beta.1 | 616 | 11/7/2023 |
2.0.0-beta.0 | 397 | 11/7/2023 |
2.0.0-alpha.7 | 449 | 10/27/2023 |
2.0.0-alpha.6 | 96 | 10/25/2023 |
2.0.0-alpha.5 | 73 | 10/20/2023 |
2.0.0-alpha.4 | 93 | 10/12/2023 |
2.0.0-alpha.3 | 120 | 9/13/2023 |
2.0.0-alpha.2 | 82 | 9/7/2023 |