diff --git a/sandbox/Example.Core.PublishHeaders/Example.Core.PublishHeaders.csproj b/sandbox/Example.Core.PublishHeaders/Example.Core.PublishHeaders.csproj index 753c5334b..8e64548a3 100644 --- a/sandbox/Example.Core.PublishHeaders/Example.Core.PublishHeaders.csproj +++ b/sandbox/Example.Core.PublishHeaders/Example.Core.PublishHeaders.csproj @@ -10,6 +10,7 @@ + diff --git a/sandbox/Example.Core.PublishHeaders/Program.cs b/sandbox/Example.Core.PublishHeaders/Program.cs index 51f0aa49f..9b42b2faf 100644 --- a/sandbox/Example.Core.PublishHeaders/Program.cs +++ b/sandbox/Example.Core.PublishHeaders/Program.cs @@ -1,9 +1,14 @@ // > nats sub bar.* using Microsoft.Extensions.Logging; using NATS.Client.Core; +using NATS.Client.Serializers.Json; var subject = "bar.xyz"; -var options = NatsOpts.Default with { LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()) }; +var options = NatsOpts.Default with +{ + LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()), + SerializerRegistry = NatsJsonSerializerRegistry.Default, +}; Print("[CON] Connecting...\n"); @@ -12,7 +17,7 @@ for (var i = 0; i < 10; i++) { Print($"[PUB] Publishing to subject ({i}) '{subject}'...\n"); - await connection.PublishAsync( + await connection.PublishAsync( subject, new Bar { Id = i, Name = "Baz" }, headers: new NatsHeaders { ["XFoo"] = $"bar{i}" }); diff --git a/sandbox/Example.Core.PublishModel/Example.Core.PublishModel.csproj b/sandbox/Example.Core.PublishModel/Example.Core.PublishModel.csproj index f0214d692..0da21d55d 100644 --- a/sandbox/Example.Core.PublishModel/Example.Core.PublishModel.csproj +++ b/sandbox/Example.Core.PublishModel/Example.Core.PublishModel.csproj @@ -10,6 +10,7 @@ + diff --git a/sandbox/Example.Core.PublishModel/Program.cs b/sandbox/Example.Core.PublishModel/Program.cs index 0b603a2fd..663fcecce 100644 --- a/sandbox/Example.Core.PublishModel/Program.cs +++ b/sandbox/Example.Core.PublishModel/Program.cs @@ -1,9 +1,13 @@ // > nats sub bar.* using Microsoft.Extensions.Logging; using NATS.Client.Core; +using NATS.Client.Serializers.Json; var subject = "bar.xyz"; -var options = NatsOpts.Default with { LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()) }; +var options = NatsOpts.Default with { + LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()), + SerializerRegistry = NatsJsonSerializerRegistry.Default, +}; Print("[CON] Connecting...\n"); @@ -12,7 +16,7 @@ for (var i = 0; i < 10; i++) { Print($"[PUB] Publishing to subject ({i}) '{subject}'...\n"); - await connection.PublishAsync(subject, new Bar { Id = i, Name = "Baz" }); + await connection.PublishAsync(subject, new Bar { Id = i, Name = "Baz" }); } void Print(string message) diff --git a/sandbox/Example.Core.SubscribeHeaders/Example.Core.SubscribeHeaders.csproj b/sandbox/Example.Core.SubscribeHeaders/Example.Core.SubscribeHeaders.csproj index f0214d692..0da21d55d 100644 --- a/sandbox/Example.Core.SubscribeHeaders/Example.Core.SubscribeHeaders.csproj +++ b/sandbox/Example.Core.SubscribeHeaders/Example.Core.SubscribeHeaders.csproj @@ -10,6 +10,7 @@ + diff --git a/sandbox/Example.Core.SubscribeHeaders/Program.cs b/sandbox/Example.Core.SubscribeHeaders/Program.cs index cc01621c6..3994f1844 100644 --- a/sandbox/Example.Core.SubscribeHeaders/Program.cs +++ b/sandbox/Example.Core.SubscribeHeaders/Program.cs @@ -1,11 +1,15 @@ // > nats pub bar.xyz --count=10 "my_message_{{ Count }}" -H X-Foo:Baz -using System.Text; using Microsoft.Extensions.Logging; using NATS.Client.Core; +using NATS.Client.Serializers.Json; var subject = "bar.*"; -var options = NatsOpts.Default with { LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()) }; +var options = NatsOpts.Default with +{ + LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()), + SerializerRegistry = NatsJsonSerializerRegistry.Default, +}; Print("[CON] Connecting...\n"); @@ -13,9 +17,9 @@ Print($"[SUB] Subscribing to subject '{subject}'...\n"); -await foreach (var msg in connection.SubscribeAsync(subject)) +await foreach (var msg in connection.SubscribeAsync(subject)) { - Print($"[RCV] {msg.Subject}: {Encoding.UTF8.GetString(msg.Data!)}\n"); + Print($"[RCV] {msg.Subject}: {msg.Data!}\n"); if (msg.Headers != null) { foreach (var (key, values) in msg.Headers) diff --git a/sandbox/Example.Core.SubscribeModel/Example.Core.SubscribeModel.csproj b/sandbox/Example.Core.SubscribeModel/Example.Core.SubscribeModel.csproj index f0214d692..0da21d55d 100644 --- a/sandbox/Example.Core.SubscribeModel/Example.Core.SubscribeModel.csproj +++ b/sandbox/Example.Core.SubscribeModel/Example.Core.SubscribeModel.csproj @@ -10,6 +10,7 @@ + diff --git a/sandbox/Example.Core.SubscribeModel/Program.cs b/sandbox/Example.Core.SubscribeModel/Program.cs index fcf9c276e..cdc4e5a87 100644 --- a/sandbox/Example.Core.SubscribeModel/Program.cs +++ b/sandbox/Example.Core.SubscribeModel/Program.cs @@ -1,8 +1,13 @@ using Microsoft.Extensions.Logging; using NATS.Client.Core; +using NATS.Client.Serializers.Json; var subject = "bar.*"; -var options = NatsOpts.Default with { LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()) }; +var options = NatsOpts.Default with +{ + LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()), + SerializerRegistry = NatsJsonSerializerRegistry.Default, +}; Print("[CON] Connecting...\n");