We're running NServiceBus 4.6 in Azure worker roles using Azure Storage Queues as the transport.
We're happy storing NServiceBus related data (sagas, subscriptions, etc) using the default Azure table storage persisters.
However we'd like to store our business entities in RavenDB to take advantage of querying and Raven's other features.
Given Azure's lack of transaction support - what is the best way to configure NServiceBus and use Raven's IDocumentStore
/ IDocumentSession
in our handlers. We want to ensure that we don't lose any data if an exception occurs.
Should we:
Use NServiceBus's
IManageUnitsOfWork
interface to open aDocumentSession
inBegin()
and then callSaveChanges()
inEnd()
if there was no exception. This is what we used to do with on-premise NServiceBus hosting and MSMQ, orOpen a new
DocumentSession
inside each of our handlers and explicitly callSaveChanges()
as soon as possible. This option would require ensuring that all our handlers are idempotent.Store everything in RavenDB, including business entities and NServiceBus data. This would avoid Azure table storage and hopefully store our data atomically.
What is the recommended configuration and is there anything else we need to consider?