From 9ae65ae5e34f21d11d8b7418f1f4f0e054883756 Mon Sep 17 00:00:00 2001 From: xhafan Date: Wed, 30 Oct 2024 09:29:23 +0100 Subject: [PATCH] #49 Could not find existing saga data when the assembly version changes - removing version from saga type --- .../PostgreSql/Sagas/PostgreSqlSagaStorage.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Rebus.PostgreSql/PostgreSql/Sagas/PostgreSqlSagaStorage.cs b/Rebus.PostgreSql/PostgreSql/Sagas/PostgreSqlSagaStorage.cs index e2adc53..cd3f4e0 100644 --- a/Rebus.PostgreSql/PostgreSql/Sagas/PostgreSqlSagaStorage.cs +++ b/Rebus.PostgreSql/PostgreSql/Sagas/PostgreSqlSagaStorage.cs @@ -3,6 +3,7 @@ using System.Linq; // ReSharper disable once RedundantUsingDirective (because .NET Core) using System.Reflection; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Npgsql; using NpgsqlTypes; @@ -413,7 +414,15 @@ async Task CreateIndex(ISagaData sagaData, PostgresConnection connection, IEnume string GetSagaTypeName(Type sagaDataType) { - return sagaDataType.FullName; + return _removeVersionFromTypeFullName(); + + // Rebus cannot find existing saga when the version changes, which breaks a long-running saga with deployments during the saga lifetime. + string _removeVersionFromTypeFullName() + { + return sagaDataType.FullName != null + ? Regex.Replace(sagaDataType.FullName, @"Version=\d+\.\d+\.\d+\.\d+, ", "") + : null; + } } static List> GetPropertiesToIndex(ISagaData sagaData, IEnumerable correlationProperties)