Skip to content

Commit

Permalink
Log warn when the client version is below 5.2.0 to make sure clients …
Browse files Browse the repository at this point in the history
…start upgrading to later versions without enforcing them to have Encrypt=true that was introduced in a breaking change in 4.x of the client
  • Loading branch information
danielmarbach committed Mar 5, 2024
1 parent 63335fb commit a0102a3
Showing 1 changed file with 17 additions and 3 deletions.
Expand Up @@ -2,13 +2,15 @@ namespace NServiceBus.Transport.SqlServer
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Transactions;
#if SYSTEMDATASQLCLIENT
using System.Data.SqlClient;
#else
using Microsoft.Data.SqlClient;
#endif
using System.Threading.Tasks;
using System.Transactions;
using DelayedDelivery;
using NServiceBus.Logging;
using Performance.TimeToBeReceived;
Expand Down Expand Up @@ -46,7 +48,7 @@ internal SqlServerTransportInfrastructure(string catalog, SettingsHolder setting
addressTranslator = new QueueAddressTranslator(catalog, "dbo", defaultSchemaOverride, queueSchemaSettings);
tableBasedQueueCache = new TableBasedQueueCache(addressTranslator, !isEncrypted);
connectionFactory = CreateConnectionFactory();

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 51 in src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
//Configure the schema and catalog for logical endpoint-based routing
var schemaAndCatalogSettings = settings.GetOrCreate<EndpointSchemaAndCatalogSettings>();
settings.GetOrCreate<EndpointInstances>().AddOrReplaceInstances("SqlServer", schemaAndCatalogSettings.ToEndpointInstances());
Expand All @@ -67,6 +69,18 @@ internal SqlServerTransportInfrastructure(string catalog, SettingsHolder setting
}
var subscriptionTableCreator = new SubscriptionTableCreator(subscriptionTableName, connectionFactory);
settings.Set(subscriptionTableCreator);

if (typeof(SqlConnection).Namespace != "Microsoft.Data.SqlClient")
{
return;
}

var informationalVersion = typeof(SqlConnection).Assembly.GetCustomAttributes().OfType<AssemblyInformationalVersionAttribute>().Single();
var currentClientVersion = new Version(informationalVersion.InformationalVersion.Split('+').First());
if (currentClientVersion < new Version(5, 2, 0))
{
Logger.WarnFormat("You are using an outdated version '{0}' of Microsoft.Data.SqlClient. We recommend using version 5.2.0 or later by adding a top-level package reference to avoid known problems in older versions of the client. Consult the SQL client release notes https://github.com/dotnet/SqlClient/blob/main/release-notes for breaking changes before upgrading.", currentClientVersion);
}
}

SqlConnectionFactory CreateConnectionFactory()
Expand Down

0 comments on commit a0102a3

Please sign in to comment.