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
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Design guidelines


In any instance where you might use a batch job or scheduled task, or in situations that involve complex, ever-changing business requirements, the saga pattern is generally a good fit. However, there are some things you should keep in mind.

Business logic only

While it may be tempting to throw a whole bunch of logic, data access, and the whole kitchen sink into a saga, this is not a good idea.

Although saga data storage is abstracted to be very easy to work with, remember that at some point, data needs to be saved using the persistence strategy you selected for your endpoint, which could be NHibernate or RavenDB. Or you could even roll your own saga storage by creating and registering an implementation of ISagaPersister (we will cover dependency injection in Chapter 7, Advanced Configuration).

No matter which persistence mechanism is used, if there are a lot of messages being processed in parallel, then there will be contention on the saga storage, which you don't want to exacerbate...