NServiceBus - How to make sure SagaData is in sync between the Worker Servers?

133 Views Asked by At

In NServiceBus 4.6.5 messages go to the Worker servers using the Round-Robin algorithm.

I have some data in the Sagas to detect business messages out of sync. That data is stored into an Oracle Database.

How to make sure all servers share the same SagaData (in sync) all the time, so that if one server makes changes to that SagaData, the other Servers SagaData gets invalidated and updated automatically?

I've been reading this and in NServiceBus 4.6.5 I'm implementing the ISagaPersister interface and persisting everything to an Oracle Database.

Thanks

1

There are 1 best solutions below

0
On

This is completely handled by your database. Every time your saga gets access its state is retrieved from the database, this isn't cached by NServiceBus. This state in the database is either locked optimistically using optimistic concurrency control or pessimistically using database locks managed by a database transaction.

If you customize the NHibernate configuration is you are using that then you might be able to configure 2nd level caching within NHibernate but this should be avoided if you are using multiple servers unless you use a distributed cache.