Once a behavior is introduced to identify the partition key for a given message, it is possible to share a Azure Table TableBatchOperation between both the Saga persistence and business data. The shared TableBatchOperation
can then be used to persist document updates for both concerns atomically.
To use the shared TableBatchOperation
in a message handler:
snippet: HandlerSharedTransaction
The TestableAzureTableStorageSession
class in the NServiceBus.Testing
namespace has been provided to facilitate testing a handler that utilizes the shared transaction feature.
For custom types that require access to the shared TableBatchOperation
:
snippet: TransactionalBatchRegisteredWithDependencyInjectionResolvedInCustomType
And alternatively to using the the extension method IMessageHandlerContext.SynchronizedStorageSession.AzureTablePersistenceSession()
:
snippet: TransactionalBatchRegisteredWithDependencyInjectionResolvedInHandler