Skip to content

Latest commit

 

History

History
23 lines (12 loc) · 1.19 KB

transactions_sharing_astp_[3,5).partial.md

File metadata and controls

23 lines (12 loc) · 1.19 KB

Sharing the transaction

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.

Within a handler method using IMessageHandlerContext

To use the shared TableBatchOperation in a message handler:

snippet: HandlerSharedTransaction

Testing

The TestableAzureTableStorageSession class in the NServiceBus.Testing namespace has been provided to facilitate testing a handler that utilizes the shared transaction feature.

With dependency injection

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