Skip to content
Mogens Heller Grabe edited this page Apr 27, 2016 · 2 revisions

ISagaStorage is Rebus' saga storage abstraction which is responsible for doing the following things:

  • insert a new saga
  • update an existing saga
  • delete an existing saga
  • find an existing saga based on the value of a "correlation property" (i.e. one of the possibly multiple properties of the saga data, which have been designated to be correlation properties beforehand)

No matter which saga storage you choose (i.e. SQL Server, in-mem, MongoDB, ...) it will expose the same behavior. Generally, the saga data will be protected from concurrency issues via optimistic locking (which uses the Revision property of the saga data), throwing appropriate ConcurrencyExceptions in case the "lock" was lost.

This ensures that the developer can write code in a saga and generally just assume that the current state of the saga data is in fact current, because if it turns out that it wasn't (i.e. the saga data was changed by someone else, e.g. another thread), the message transaction rolls back (due to the ConcurrencyException) and message delivery is retried.

How to configure the saga storage

The saga storage is configured with the Sagas configurer, e.g. like so:

Configure.With(...)
    .(...)
    .Sagas(s => s.StoreInSqlServer(connectionString, "Sagas", "SagaIndex"))
    .(...)

causing the saga data to be saved to the [Sagas] table, using the [SagaIndex] table to store extracted correlation property key-value pairs.

Other saga storages

Rebus has saga storages for other databases too, e.g. for MongoDB, PostgreSQL, and RavenDB.

Clone this wiki locally