We're happy to announce a new NATS .NET release version 2.5.7. This release includes various minor fixes and features. There is also a breaking change in the dependency injection package; please make sure to check the details below.
What's Changed
- Add CreateOrUpdateStoreAsync by @Ivandemidov00 in #707
- Implement Lame Duck Mode Event Handler by @pzajaczkowski in #716
- Add callback to NatsAuthOpts that allows refreshing a Token by @garrett-sutton in #712
- Add NatsClient to DI by @mtmk in #689
- Fix telemetry header readonly error by @mtmk in #719
Breaking Change to NATS.Extensions.Microsoft.DependencyInjection Default Serialization
Since the introduction of INatsClient
interface we have made developers and newcomers life easier by providing a sensible default serialization setting that would avoid surprises, and allow ad hoc JSON serialization of custom objects out of the box. With the change Add NatsClient to DI #689 we are now introducing these defaults into the NATS.Extensions.Microsoft.DependencyInjection package. If you are using this package and want to stay with the old defaults you must change the following options:
- BoundedChannelFullMode option is applied to the subscription channels and the connection default is to DropNewest. The default applied to the
NatsClient
instances and in turn to the NATS.Extensions.Microsoft.DependencyInjection package is now to wait when the channel is full. You can set it back to the connection default or if you are happy to go with the new default please make sure to test your application. - DefaultSerializerRegistry of NATS.Extensions.Microsoft.DependencyInjection package is the main change with this release, allowing applications to automatically serialize ad hoc objects to JSON, while serializing primitives like byte arrays, numbers, dates, and strings to their raw values using the same serializer registry as
NatsClient
. We are also deprecatingAddJsonSerialization
methods to avaoid confusion. They are only marked asObsolete
for now, so there is no need to change that with this release.
services.AddNatsClient(nats =>
{
// DropNewest was the default, now it's set to Wait. To keep
// the behavior before this PR add the following line:
nats.WithSubPendingChannelFullMode(BoundedChannelFullMode.DropNewest);
// If you were not using custom serializer which doesn't derialize ad hoc JSON
// objects make sure to add the following to keep to original serializer settings:
nats.WithSerializerRegistry(NatsDefaultSerializerRegistry.Default);
});
For more information, please check the PR Add NatsClient to DI #689. Overall, we don't expect many application would be affected by this change; nevertheless, feel free to ask for clarification in the #dotnet channel on http://slack.nats.io if needed.
New Contributors
- @garrett-sutton made their first contribution in #712
Full Changelog: v2.5.6...v2.5.7