Book Image

MASTERING NSERVICEBUS AND PERSISTENCE

By : Richard L Helton
Book Image

MASTERING NSERVICEBUS AND PERSISTENCE

By: Richard L Helton

Overview of this book

Table of Contents (15 chapters)
Mastering NServiceBus and Persistence
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using saga and NHibernate


We will walk through a modified example of a basic saga, originally from https://github.com/jkillingsworth/NServiceBus-BasicSagas. However, this example has been modified to use NHibernate, which uses a local SQL Express database. NHibernate was added using some of the steps from http://docs.particular.net/nservicebus/relational-persistence-using-nhibernate---nservicebus-4.x. We also added logging using the NLog framework to log functionalities as we go. The NHibernate ORM framework was chosen because it can connect to a multitude of different databases using the same code, the difference being the connection string in the app.config file for the different databases.

To elaborate on this saga example, there is a MySaga program that directs the messages while saving a saga instance as the messages are being moved. The saga persistence keeps track of the information that we defined to be saved in a saga entity object. The saga acts as an anchor that we can persist...