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 1, 2024
1 parent c9b277b commit 160b548
Showing 1 changed file with 18 additions and 0 deletions.
Expand Up @@ -3,9 +3,15 @@ namespace NServiceBus.Transport.SqlServer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
#if SYSTEMDATASQLCLIENT
using System.Data.SqlClient;
#else
using Microsoft.Data.SqlClient;
#endif
using Logging;
using NServiceBus.Transport.SqlServer.PubSub;
using Transport;
Expand All @@ -21,6 +27,18 @@ internal SqlServerTransportInfrastructure(SqlServerTransport transport, HostSett

tableBasedQueueCache = new TableBasedQueueCache(addressTranslator, !isEncrypted);
connectionFactory = CreateConnectionFactory();

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 taking an explicit package dependency to avoid issues with memory leaks or transactions running on .NET in the driver.", currentClientVersion);
}
}

public async Task ConfigureSubscriptions(string catalog, CancellationToken cancellationToken = default)
Expand Down

0 comments on commit 160b548

Please sign in to comment.