Once a behavior is introduced to identify the partition key for a given message, it is possible to share a batch, represented in Azure Table by List<TableTransactionAction>
between both the Saga persistence and business data. This list can then be used to persist document updates for both concerns atomically.
To use the shared List<TableTransactionAction>
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 List<TableTransactionAction>
:
snippet: TransactionalBatchRegisteredWithDependencyInjectionResolvedInCustomType
And alternatively to using the the extension method IMessageHandlerContext.SynchronizedStorageSession.AzureTablePersistenceSession()
:
snippet: TransactionalBatchRegisteredWithDependencyInjectionResolvedInHandler