Book Image

Learning NServiceBus - Second Edition

By : David Boike
Book Image

Learning NServiceBus - Second Edition

By: David Boike

Overview of this book

Table of Contents (18 chapters)
Learning NServiceBus Second Edition
About the Author
About the Reviewers

Defining a saga

A saga is a different way to represent these long-running business processes, by taking multiple message handlers, similar to the ones we've created in the previous chapters, and organizing them together with shared state that persists over time. A message designed to start the process will create a new instance of stored saga data, and subsequent messages will all share and update this data throughout the saga's lifetime. Each saga message handler retains all of the same capabilities, such as fault tolerance and automatic retry, that we've come to rely upon, but with the simple addition of the stored state.

To demonstrate how to build a saga, we will revisit the example of the project from the first two chapters, modified slightly to support the unobtrusive mode conventions we learned in Chapter 5, Advanced Messaging. We will be implementing email verification, meaning that before the user is created in the database, we will send them an email containing a code. Then the...