diff --git a/doc/content/4.support/4.upgrade.md b/doc/content/4.support/4.upgrade.md index a23290d236c..e28b3e4d5e1 100644 --- a/doc/content/4.support/4.upgrade.md +++ b/doc/content/4.support/4.upgrade.md @@ -1,5 +1,24 @@ # Upgrading +## Version 8.1 + +MassTransit version 8.1 is focused on improving cross-component integration between various components like the (mediator <-> bus, bus1 <-> bus2, etc). In previous versions of MassTransit, the `ConsumeContext` was used to send messages. This approach worked well for a long time, but as more components like the Mediator, MultiBus, and Riders became available, issues arose with resolving the correct `ConsumeContext`. + +To address this issue, MassTransit v8.1 introduces a new capability to keep track of the owning component of the `ConsumeContext`. When the `ConsumeContext` is owned by another component, the library only copies necessary data such as headers, payloads, and source address. This change opens up the possibility of consuming message by the Mediator and sending it directly to the bus by resolving `IPublishEndpoint` or `ISendEndpointProvider`. + +As this is a minor release, we have made every effort to ensure minimal impact on existing customer integrations. However, to use this capability, small changes are required. Previously, `IServiceProvider` was used as a parameter to most configuration methods, with this change `IRegistrationContext` should be used instead. + +### Sagas +In MassTransit v8.1, the registration of `ISagaRepository` in the container has been updated. Previously, this interface was responsible for both retrieving and querying sagas from the repository. With this release, we have decided to separate these responsibilities, resulting in the registering of two additional interfaces in container: + +- `ILoadSagaRepository` - should be used to load sagas by id. +- `IQuerySagaRepository` - should be used to query saga ids by expression. + +Both of these interfaces are registered in the container as singletons. +::alert{type="warning"} +The registration `ISagaRepository` will be removed from the container, so it is recommended to start using these new interfaces instead. +:: + ## Version 8 MassTransit v8 is the first major release since the availability of .NET 6. MassTransit v8 works a significant portion of the underlying components into a more manageable solution structure. Focused on the developer experience, while maintaining compatibility with previous versions, this release brings together the entire MassTransit stack. diff --git a/src/MassTransit/Configuration/DependencyInjection/DependencyInjectionExtensions.cs b/src/MassTransit/Configuration/DependencyInjection/DependencyInjectionExtensions.cs index 60beda2edb3..e91f9b11796 100644 --- a/src/MassTransit/Configuration/DependencyInjection/DependencyInjectionExtensions.cs +++ b/src/MassTransit/Configuration/DependencyInjection/DependencyInjectionExtensions.cs @@ -24,6 +24,8 @@ public static void UseServiceScope(this IConsumePipeConfigurator configurator, I configurator.AddPrePipeSpecification(specification); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Creates a single scope for the receive endpoint that is used by all consumers, sagas, messages, etc. /// diff --git a/src/MassTransit/Configuration/DependencyInjection/DependencyInjectionReceiveEndpointExtensions.cs b/src/MassTransit/Configuration/DependencyInjection/DependencyInjectionReceiveEndpointExtensions.cs index 10ddb5c42b6..cffefb5e819 100644 --- a/src/MassTransit/Configuration/DependencyInjection/DependencyInjectionReceiveEndpointExtensions.cs +++ b/src/MassTransit/Configuration/DependencyInjection/DependencyInjectionReceiveEndpointExtensions.cs @@ -27,6 +27,8 @@ public static void Consumer(this IReceiveEndpointConfigurator configurator, I configurator.Consumer(consumerFactory, configure); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Registers a consumer given the lifetime scope specified /// @@ -67,6 +69,8 @@ public static void Consumer(this IBatchConfigurator /// Connect a consumer with a consumer factory method /// @@ -110,6 +114,8 @@ public static ConnectHandle ConnectConsumer(this IConsumePipeConnecto return connector.ConnectConsumer(consumerFactory, pipeSpecifications); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Connect a consumer to the bus/mediator /// @@ -149,6 +155,8 @@ public static void Saga(this IReceiveEndpointConfigurator configurator, IRegi configurator.Saga(repository, configure); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Registers a saga using the container that has the repository resolved from the container /// @@ -183,6 +191,8 @@ public static void StateMachineSaga(this IReceiveEndpointConfigurator configurator.StateMachineSaga(stateMachine, repository, configure); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Subscribe a state machine saga to the endpoint /// @@ -219,6 +229,8 @@ public static void StateMachineSaga(this IReceiveEndpointConfigurator configurator.StateMachineSaga(stateMachine, repository, configure); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Subscribe a state machine saga to the endpoint /// @@ -250,6 +262,8 @@ public static void ExecuteActivityHost(this IReceiveEndpo configurator.ExecuteActivityHost(compensateAddress, factory, configure); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] public static void ExecuteActivityHost(this IReceiveEndpointConfigurator configurator, Uri compensateAddress, IServiceProvider provider, Action> configure = null) where TActivity : class, IExecuteActivity @@ -274,6 +288,8 @@ public static void ExecuteActivityHost(this IReceiveEndpo configurator.ExecuteActivityHost(factory, configure); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] public static void ExecuteActivityHost(this IReceiveEndpointConfigurator configurator, IServiceProvider provider, Action> configure = null) where TActivity : class, IExecuteActivity @@ -298,6 +314,8 @@ public static void CompensateActivityHost(this IReceiveEndpoint configurator.CompensateActivityHost(factory, configure); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] public static void CompensateActivityHost(this IReceiveEndpointConfigurator configurator, IServiceProvider provider, Action> configure = null) where TActivity : class, ICompensateActivity diff --git a/src/MassTransit/Configuration/InMemoryOutboxConfigurationExtensions.cs b/src/MassTransit/Configuration/InMemoryOutboxConfigurationExtensions.cs index a3d16670b41..be2b02ed57c 100644 --- a/src/MassTransit/Configuration/InMemoryOutboxConfigurationExtensions.cs +++ b/src/MassTransit/Configuration/InMemoryOutboxConfigurationExtensions.cs @@ -33,6 +33,8 @@ public static void UseInMemoryOutbox(this IPipeConfigurator configurator.AddPipeSpecification(specification); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Includes an outbox in the consume filter path, which delays outgoing messages until the return path /// of the pipeline returns to the outbox filter. At this point, the message execution pipeline should be @@ -70,6 +72,8 @@ public static void UseInMemoryOutbox(this IConsumePipeConfigurator configurator, var observer = new InMemoryOutboxConfigurationObserver(context, configurator, configure); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Includes an outbox in the consume filter path, which delays outgoing messages until the return path /// of the pipeline returns to the outbox filter. At this point, the message execution pipeline should be @@ -104,6 +108,8 @@ public static void UseInMemoryOutbox(this IConsumerConfigurator /// Includes an outbox in the consume filter path, which delays outgoing messages until the return path /// of the pipeline returns to the outbox filter. At this point, the message execution pipeline should be @@ -140,6 +146,8 @@ public static void UseInMemoryOutbox(this ISagaConfigurator config configurator.ConnectSagaConfigurationObserver(observer); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Includes an outbox in the consume filter path, which delays outgoing messages until the return path /// of the pipeline returns to the outbox filter. At this point, the message execution pipeline should be @@ -176,6 +184,8 @@ public static void UseInMemoryOutbox(this IHandlerConfigurator /// Includes an outbox in the consume filter path, which delays outgoing messages until the return path /// of the pipeline returns to the outbox filter. At this point, the message execution pipeline should be diff --git a/src/MassTransit/Configuration/JobServiceConfigurationExtensions.cs b/src/MassTransit/Configuration/JobServiceConfigurationExtensions.cs index 916ff8a10de..5a2f6150b1b 100644 --- a/src/MassTransit/Configuration/JobServiceConfigurationExtensions.cs +++ b/src/MassTransit/Configuration/JobServiceConfigurationExtensions.cs @@ -28,6 +28,8 @@ public static IServiceInstanceConfigurator ConfigureJobServiceEndpoints(th return configurator; } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Configures support for job consumers on the service instance, which supports executing long-running jobs without blocking the consumer pipeline. /// Job consumers use multiple state machines to track jobs, each of which runs on its own dedicated receive endpoint. Multiple service @@ -72,6 +74,8 @@ public static IServiceInstanceConfigurator ConfigureJobServiceEndpoints(th return configurator; } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Configures support for job consumers on the service instance, which supports executing long-running jobs without blocking the consumer pipeline. /// Job consumers use multiple state machines to track jobs, each of which runs on its own dedicated receive endpoint. Multiple service diff --git a/src/MassTransit/Configuration/JobServiceContainerConfigurationExtensions.cs b/src/MassTransit/Configuration/JobServiceContainerConfigurationExtensions.cs index 524062ac5b5..1024a24b403 100644 --- a/src/MassTransit/Configuration/JobServiceContainerConfigurationExtensions.cs +++ b/src/MassTransit/Configuration/JobServiceContainerConfigurationExtensions.cs @@ -21,6 +21,8 @@ public static IJobServiceConfigurator ConfigureSagaRepositories(this IJobService return configurator; } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Configure the job server saga repositories to resolve from the container. /// diff --git a/src/MassTransit/Testing/ExtensionMethodsForSagas.cs b/src/MassTransit/Testing/ExtensionMethodsForSagas.cs index 43b40df88ad..ae5e8b63a9d 100644 --- a/src/MassTransit/Testing/ExtensionMethodsForSagas.cs +++ b/src/MassTransit/Testing/ExtensionMethodsForSagas.cs @@ -40,7 +40,7 @@ public static class ExtensionMethodsForSagas return default; } - static async Task ShouldContainSaga(this IQuerySagaRepository repository, Guid correlationId, TimeSpan timeout) + public static async Task ShouldContainSaga(this IQuerySagaRepository repository, Guid correlationId, TimeSpan timeout) where TSaga : class, ISaga { var giveUpAt = DateTime.Now + timeout; @@ -69,7 +69,7 @@ public static class ExtensionMethodsForSagas return TaskUtil.Faulted(new ArgumentException("Does not support IQuerySagaRepository", nameof(repository))); } - static async Task ShouldContainSaga(this ILoadSagaRepository repository, Guid correlationId, Func condition, + public static async Task ShouldContainSaga(this ILoadSagaRepository repository, Guid correlationId, Func condition, TimeSpan timeout) where TSaga : class, ISaga { @@ -99,7 +99,7 @@ public static class ExtensionMethodsForSagas return TaskUtil.Faulted(new ArgumentException("Does not support IQuerySagaRepository", nameof(repository))); } - static async Task ShouldNotContainSaga(this ILoadSagaRepository repository, Guid correlationId, TimeSpan timeout) + public static async Task ShouldNotContainSaga(this ILoadSagaRepository repository, Guid correlationId, TimeSpan timeout) where TSaga : class, ISaga { var giveUpAt = DateTime.Now + timeout; @@ -119,7 +119,7 @@ public static class ExtensionMethodsForSagas return instance.CorrelationId; } - static async Task ShouldNotContainSaga(this IQuerySagaRepository repository, Guid correlationId, TimeSpan timeout) + public static async Task ShouldNotContainSaga(this IQuerySagaRepository repository, Guid correlationId, TimeSpan timeout) where TSaga : class, ISaga { var giveUpAt = DateTime.Now + timeout; diff --git a/src/MassTransit/Testing/Implementations/BaseSagaTestHarness.cs b/src/MassTransit/Testing/Implementations/BaseSagaTestHarness.cs index 6b1a1c4f28b..77430d62eb2 100644 --- a/src/MassTransit/Testing/Implementations/BaseSagaTestHarness.cs +++ b/src/MassTransit/Testing/Implementations/BaseSagaTestHarness.cs @@ -11,9 +11,10 @@ namespace MassTransit.Testing.Implementations public abstract class BaseSagaTestHarness where TSaga : class, ISaga { - protected BaseSagaTestHarness(ISagaRepository repository, TimeSpan testTimeout) + protected BaseSagaTestHarness(IQuerySagaRepository querySagaRepository, ILoadSagaRepository loadSagaRepository, TimeSpan testTimeout) { - QuerySagaRepository = repository as IQuerySagaRepository; + QuerySagaRepository = querySagaRepository; + LoadSagaRepository = loadSagaRepository; TestTimeout = testTimeout; } @@ -21,6 +22,7 @@ protected BaseSagaTestHarness(ISagaRepository repository, TimeSpan testTi protected TimeSpan TestTimeout { get; } protected IQuerySagaRepository QuerySagaRepository { get; } + protected ILoadSagaRepository LoadSagaRepository { get; } /// /// Waits until a saga exists with the specified correlationId @@ -30,18 +32,16 @@ protected BaseSagaTestHarness(ISagaRepository repository, TimeSpan testTi /// public async Task Exists(Guid correlationId, TimeSpan? timeout = default) { - if (QuerySagaRepository == null) - throw new InvalidOperationException("The repository does not support Query operations"); + if (LoadSagaRepository == null) + throw new InvalidOperationException("The repository does not support Load operations"); var giveUpAt = DateTime.Now + (timeout ?? TestTimeout); - var query = new SagaQuery(x => x.CorrelationId == correlationId); - while (DateTime.Now < giveUpAt) { - var saga = (await QuerySagaRepository.Find(query).ConfigureAwait(false)).FirstOrDefault(); - if (saga != Guid.Empty) - return saga; + var saga = await LoadSagaRepository.Load(correlationId).ConfigureAwait(false); + if (saga != null) + return saga.CorrelationId; await Task.Delay(10).ConfigureAwait(false); } @@ -84,24 +84,22 @@ public async Task> Match(Expression> filter, TimeS /// public async Task NotExists(Guid correlationId, TimeSpan? timeout = default) { - if (QuerySagaRepository == null) - throw new InvalidOperationException("The repository does not support Query operations"); + if (LoadSagaRepository == null) + throw new InvalidOperationException("The repository does not support Load operations"); var giveUpAt = DateTime.Now + (timeout ?? TestTimeout); - var query = new SagaQuery(x => x.CorrelationId == correlationId); - - Guid? saga = default; + TSaga saga = default; while (DateTime.Now < giveUpAt) { - saga = (await QuerySagaRepository.Find(query).ConfigureAwait(false)).FirstOrDefault(); - if (saga == Guid.Empty) + saga = await LoadSagaRepository.Load(correlationId).ConfigureAwait(false); + if (saga == null) return default; await Task.Delay(10).ConfigureAwait(false); } - return saga; + return saga.CorrelationId; } } } diff --git a/src/MassTransit/Testing/Implementations/RegistrationSagaStateMachineTestHarness.cs b/src/MassTransit/Testing/Implementations/RegistrationSagaStateMachineTestHarness.cs index c843a8187ee..1c6f153f636 100644 --- a/src/MassTransit/Testing/Implementations/RegistrationSagaStateMachineTestHarness.cs +++ b/src/MassTransit/Testing/Implementations/RegistrationSagaStateMachineTestHarness.cs @@ -17,9 +17,9 @@ public class RegistrationSagaStateMachineTestHarness : where TInstance : class, SagaStateMachineInstance where TStateMachine : SagaStateMachine { - public RegistrationSagaStateMachineTestHarness(ISagaRepositoryDecoratorRegistration registration, ISagaRepository repository, - TStateMachine stateMachine) - : base(repository, registration.TestTimeout) + public RegistrationSagaStateMachineTestHarness(ISagaRepositoryDecoratorRegistration registration, + IQuerySagaRepository querySagaRepository, ILoadSagaRepository loadSagaRepository, TStateMachine stateMachine) + : base(querySagaRepository, loadSagaRepository, registration.TestTimeout) { StateMachine = stateMachine; Consumed = registration.Consumed; diff --git a/src/MassTransit/Testing/Implementations/RegistrationSagaTestHarness.cs b/src/MassTransit/Testing/Implementations/RegistrationSagaTestHarness.cs index fd2af393f93..395ea1a1eb5 100644 --- a/src/MassTransit/Testing/Implementations/RegistrationSagaTestHarness.cs +++ b/src/MassTransit/Testing/Implementations/RegistrationSagaTestHarness.cs @@ -8,8 +8,9 @@ public class RegistrationSagaTestHarness : ISagaTestHarness where TSaga : class, ISaga { - public RegistrationSagaTestHarness(ISagaRepositoryDecoratorRegistration registration, ISagaRepository repository) - : base(repository, registration.TestTimeout) + public RegistrationSagaTestHarness(ISagaRepositoryDecoratorRegistration registration, ISagaRepository repository, + ILoadSagaRepository loadRepository, IQuerySagaRepository queryRepository) + : base(queryRepository, loadRepository, registration.TestTimeout) { Consumed = registration.Consumed; Created = registration.Created; diff --git a/src/MassTransit/Testing/Implementations/StateMachineSagaTestHarness.cs b/src/MassTransit/Testing/Implementations/StateMachineSagaTestHarness.cs index 5a64a58e3ee..8a1f5903208 100644 --- a/src/MassTransit/Testing/Implementations/StateMachineSagaTestHarness.cs +++ b/src/MassTransit/Testing/Implementations/StateMachineSagaTestHarness.cs @@ -13,8 +13,10 @@ public class StateMachineSagaTestHarness : where TInstance : class, SagaStateMachineInstance where TStateMachine : SagaStateMachine { - public StateMachineSagaTestHarness(BusTestHarness testHarness, ISagaRepository repository, TStateMachine stateMachine, string queueName) - : base(testHarness, repository, queueName) + public StateMachineSagaTestHarness(BusTestHarness testHarness, ISagaRepository repository, + IQuerySagaRepository querySagaRepository, ILoadSagaRepository loadSagaRepository, TStateMachine stateMachine, + string queueName) + : base(testHarness, repository, querySagaRepository, loadSagaRepository, queueName) { StateMachine = stateMachine; } diff --git a/src/MassTransit/Testing/SagaTestHarness.cs b/src/MassTransit/Testing/SagaTestHarness.cs index 07f5f2cf53b..9e4dfbd122b 100644 --- a/src/MassTransit/Testing/SagaTestHarness.cs +++ b/src/MassTransit/Testing/SagaTestHarness.cs @@ -12,8 +12,9 @@ public class SagaTestHarness : readonly SagaList _created; readonly SagaList _sagas; - public SagaTestHarness(BusTestHarness testHarness, ISagaRepository repository, string queueName) - : base(repository, testHarness.TestTimeout) + public SagaTestHarness(BusTestHarness testHarness, ISagaRepository repository, IQuerySagaRepository querySagaRepository, + ILoadSagaRepository loadSagaRepository, string queueName) + : base(querySagaRepository, loadSagaRepository, testHarness.TestTimeout) { _consumed = new ReceivedMessageList(testHarness.TestTimeout, testHarness.InactivityToken); _created = new SagaList(testHarness.TestTimeout, testHarness.InactivityToken); diff --git a/src/MassTransit/Testing/SagaTestHarnessExtensions.cs b/src/MassTransit/Testing/SagaTestHarnessExtensions.cs index 25d3bd573fb..b2bdc3b7951 100644 --- a/src/MassTransit/Testing/SagaTestHarnessExtensions.cs +++ b/src/MassTransit/Testing/SagaTestHarnessExtensions.cs @@ -10,7 +10,7 @@ public static SagaTestHarness Saga(this BusTestHarness harness, string que { var repository = new InMemorySagaRepository(); - return new SagaTestHarness(harness, repository, queueName); + return new SagaTestHarness(harness, repository, repository, repository, queueName); } public static SagaTestHarness Saga(this BusTestHarness harness, ISagaRepository repository, string queueName = null) @@ -19,7 +19,10 @@ public static SagaTestHarness Saga(this BusTestHarness harness, ISagaRepos if (repository == null) throw new ArgumentNullException(nameof(repository)); - return new SagaTestHarness(harness, repository, queueName); + var querySagaRepository = repository as IQuerySagaRepository; + var loadSagaRepository = repository as ILoadSagaRepository; + + return new SagaTestHarness(harness, repository, querySagaRepository, loadSagaRepository, queueName); } } } diff --git a/src/MassTransit/Testing/StateMachineSagaTestingExtensions.cs b/src/MassTransit/Testing/StateMachineSagaTestingExtensions.cs index 8fbc1aada68..fb272b95a2e 100644 --- a/src/MassTransit/Testing/StateMachineSagaTestingExtensions.cs +++ b/src/MassTransit/Testing/StateMachineSagaTestingExtensions.cs @@ -19,7 +19,7 @@ public static ISagaStateMachineTestHarness StateMachin var repository = new InMemorySagaRepository(); - return new StateMachineSagaTestHarness(harness, repository, stateMachine, queueName); + return new StateMachineSagaTestHarness(harness, repository, repository, repository, stateMachine, queueName); } public static ISagaStateMachineTestHarness StateMachineSaga(this BusTestHarness harness, @@ -33,7 +33,10 @@ public static ISagaStateMachineTestHarness StateMachin if (repository == null) throw new ArgumentNullException(nameof(repository)); - return new StateMachineSagaTestHarness(harness, repository, stateMachine, queueName); + var querySagaRepository = repository as IQuerySagaRepository; + var loadSagaRepository = repository as ILoadSagaRepository; + return new StateMachineSagaTestHarness(harness, repository, querySagaRepository, loadSagaRepository, stateMachine, + queueName); } public static TInstance ContainsInState(this ISagaList sagas, Guid correlationId, TStateMachine machine, diff --git a/src/Persistence/MassTransit.EntityFrameworkCoreIntegration/Configuration/EntityFrameworkOutboxConfigurationExtensions.cs b/src/Persistence/MassTransit.EntityFrameworkCoreIntegration/Configuration/EntityFrameworkOutboxConfigurationExtensions.cs index d996369b8af..543786107f8 100644 --- a/src/Persistence/MassTransit.EntityFrameworkCoreIntegration/Configuration/EntityFrameworkOutboxConfigurationExtensions.cs +++ b/src/Persistence/MassTransit.EntityFrameworkCoreIntegration/Configuration/EntityFrameworkOutboxConfigurationExtensions.cs @@ -51,6 +51,8 @@ public static void UseEntityFrameworkOutbox(this IReceiveEndpointCon configurator.ConnectSagaConfigurationObserver(observer); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Configure the Entity Framework outbox on the receive endpoint /// diff --git a/src/Persistence/MassTransit.MongoDbIntegration/Configuration/MongoDbOutboxConfigurationExtensions.cs b/src/Persistence/MassTransit.MongoDbIntegration/Configuration/MongoDbOutboxConfigurationExtensions.cs index 36ab58541e0..b3292acd779 100644 --- a/src/Persistence/MassTransit.MongoDbIntegration/Configuration/MongoDbOutboxConfigurationExtensions.cs +++ b/src/Persistence/MassTransit.MongoDbIntegration/Configuration/MongoDbOutboxConfigurationExtensions.cs @@ -46,6 +46,8 @@ public static void UseMongoDbOutbox(this IReceiveEndpointConfigurator configurat configurator.ConnectSagaConfigurationObserver(observer); } + [Obsolete( + "Use the IRegistrationContext overload to ensure message scope is properly handled. For more information, visit https://masstransit.io/support/upgrade#version-8.1")] /// /// Configure the Entity Framework outbox on the receive endpoint /// diff --git a/tests/MassTransit.HangfireIntegration.Tests/Reschedule_Specs.cs b/tests/MassTransit.HangfireIntegration.Tests/Reschedule_Specs.cs index 57f785c1b4f..1ad16d72ec5 100644 --- a/tests/MassTransit.HangfireIntegration.Tests/Reschedule_Specs.cs +++ b/tests/MassTransit.HangfireIntegration.Tests/Reschedule_Specs.cs @@ -31,12 +31,13 @@ public async Task Should_reschedule_the_message_with_a_new_token_id() await InputQueueSendEndpoint.Send(new StopCommand(correlationId)); - Guid? saga = await _repository.ShouldNotContainSaga(correlationId, TestTimeout); + Guid? saga = await LoadSagaRepository.ShouldNotContainSaga(correlationId, TestTimeout); Assert.IsNull(saga); } InMemorySagaRepository _repository; + ILoadSagaRepository LoadSagaRepository => _repository; TestStateMachine _machine; Task> _rescheduled; diff --git a/tests/MassTransit.QuartzIntegration.Tests/Reschedule_Specs.cs b/tests/MassTransit.QuartzIntegration.Tests/Reschedule_Specs.cs index 260738fddf2..dfe2c1fd749 100644 --- a/tests/MassTransit.QuartzIntegration.Tests/Reschedule_Specs.cs +++ b/tests/MassTransit.QuartzIntegration.Tests/Reschedule_Specs.cs @@ -31,12 +31,13 @@ public async Task Should_reschedule_the_message_with_a_new_token_id() await InputQueueSendEndpoint.Send(new StopCommand(correlationId)); - Guid? saga = await _repository.ShouldNotContainSaga(correlationId, TestTimeout); + Guid? saga = await LoadSagaRepository.ShouldNotContainSaga(correlationId, TestTimeout); Assert.IsNull(saga); } InMemorySagaRepository _repository; + ILoadSagaRepository LoadSagaRepository => _repository; TestStateMachine _machine; Task> _rescheduled; diff --git a/tests/MassTransit.Tests/SagaStateMachineTests/CatchFault_Specs.cs b/tests/MassTransit.Tests/SagaStateMachineTests/CatchFault_Specs.cs index a3ad84860f6..077854ec408 100644 --- a/tests/MassTransit.Tests/SagaStateMachineTests/CatchFault_Specs.cs +++ b/tests/MassTransit.Tests/SagaStateMachineTests/CatchFault_Specs.cs @@ -178,7 +178,7 @@ public async Task Should_receive_the_caught_fault_response() Assert.AreEqual(message.CorrelationId, context.CorrelationId); - Assert.That(await _repository.ShouldNotContainSaga(message.CorrelationId, TestTimeout), Is.Null); + Assert.That(await LoadSagaRepository.ShouldNotContainSaga(message.CorrelationId, TestTimeout), Is.Null); } protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator) @@ -191,6 +191,7 @@ protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpoin TestStateMachine _machine; InMemorySagaRepository _repository; + ILoadSagaRepository LoadSagaRepository => _repository; class Instance : diff --git a/tests/MassTransit.Tests/SagaStateMachineTests/Finalize_Specs.cs b/tests/MassTransit.Tests/SagaStateMachineTests/Finalize_Specs.cs index b3967176c17..d66284a3166 100644 --- a/tests/MassTransit.Tests/SagaStateMachineTests/Finalize_Specs.cs +++ b/tests/MassTransit.Tests/SagaStateMachineTests/Finalize_Specs.cs @@ -14,6 +14,7 @@ public class Finalize_Specs TestStateMachine _machine; InMemorySagaRepository _repository; + ILoadSagaRepository LoadSagaRepository => _repository; [Test] public async Task Should_remove_saga_when_completed_in_whenenter() @@ -28,7 +29,7 @@ public async Task Should_remove_saga_when_completed_in_whenenter() _taskCompletionSource.SetResult(true); - saga = await _repository.ShouldNotContainSaga(correlationId, TestTimeout); + saga = await LoadSagaRepository.ShouldNotContainSaga(correlationId, TestTimeout); Assert.IsFalse(saga.HasValue); }