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


Today's distributed applications need to be built on the principles of asynchronous messaging in order to be successful. While you could try to build this infrastructure yourself, it is much better to lean on the proven experience of experts of this field. NServiceBus is a framework that gives you a proven asynchronous messaging API and much more.

This book will be your guide to NServiceBus. From sending a simple message to publishing events, implementing complex time-dependent business processes, and deploying systems to production, you'll learn everything you need to know to start building complex distributed systems in no time.

What this book covers

Chapter 1, Getting on the IBus, introduces NServiceBus and shows you how to start using the framework. You will learn how to download the framework and send your first message with it.

Chapter 2, Messaging Patterns, discusses the asynchronous messaging theory and introduces the concept of Publish/Subscribe, showing how we can achieve decoupling by publishing events.

Chapter 3, Preparing for Failure, covers concepts such as automatic retry to give you the ability to build a system that can deal with failures.

Chapter 4, Hosting, shows how to run and configure NServiceBus to run both within its own host process (as a console application or Windows service), and when hosted in a larger application such as a web project.

Chapter 5, Advanced Messaging, delves into advanced topics that will allow you to make the most out of the framework's messaging capabilities.

Chapter 6, Sagas, introduces the long-running business process known as a saga and explains how they are built and tested.

Chapter 7, Advanced Configuration, explains how NServiceBus extends and modifies itself to fit any situation or need.

Chapter 8, The Service Platform, introduces the extra tools that help you to build, debug, and manage a distributed system from development and into production.

Chapter 9, Administration, shows you how to deploy, monitor, and scale a successful NServiceBus system in a production environment.

Chapter 10, Where to Go from Here?, summarizes what you have learned in this book and lists additional sources of information.

What you need for this book

This book covers NServiceBus 5.0, and the requirements for this book closely mirror the software it covers:

  • Microsoft .NET Framework 4.5

  • Visual Studio 2013 or later versions

Additionally, the code samples use ASP.NET MVC 5 for web projects.

Who this book is for

This book is for senior developers and software architects who need to build distributed software systems and software for enterprises. It is assumed that you are quite familiar with the .NET Framework. A passing understanding of ASP.NET MVC concepts will also be helpful when discussing web-based projects.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "When we included the NServiceBus.Host NuGet package, a reference to NServiceBus.Host.exe was added to the class project."

A block of code is set as follows:

public interface IUserCreatedEvent : IEvent
  Guid UserId{ get; set; }
  string Name { get; set; }
  string EmailAddress { get; set; }

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public interface IUserCreatedEvent : IEvent
  Guid UserId{ get; set; }
  string Name { get; set; }
  string EmailAddress { get; set; }

Any command-line input or output is written as follows:

PM> Install-Package NServiceBus.Host –ProjectName UserService

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "In the Solution Explorer, right-click on the solution file and click on Properties."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.