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

Preface

Starting with the basics of NServiceBus (NSB), this book will provide you with all the skills you need to successfully design, develop, and architect C# enterprise systems with NSB. We will walk through many enterprise NSB scenarios with different persistence models. Some of these enterprise solutions will include additional frameworks, such as Model-View-Controller, Entity Frameworks, NHibernate, SFTP, and WCF. There will be discussions on MongoDB, RavenDB, and NHibernate as they relate to NSB. The Particular Service Platform, including ServiceControl, ServicePulse, and ServiceInsight, will be discussed at length with examples.

You will be taken through IBus characteristics, followed by the Persistent and NServiceBus saga architectures. You will get to know about the basics of persistence and the supporting frameworks for persistence, followed by SQL queuing and database logging. This will be followed by an in-depth look at the saga architecture, covering the mechanics, message mapping, and internal configuration, as well as tips on how to avoid certain common errors.

We will discuss how NSB provides an enhanced quality of software through the use of security, logging, monitoring, notification, and persisting objects and messages. There will be many examples. We will end the book with future enhancements to NSB, how NSB is part of the cloud space, and how it finds itself in use in the mobile world.

What this book covers

Chapter 1, NServiceBus Persistence Introduction, will discuss NSB and the basic persistence design pattern it uses, which include the sagas, gateways, subscriptions, messages, and timeout design patterns. We will also discuss the benefits of using NSB, and what it brings to the table in terms of software design.

Chapter 2, The NServiceBus Architecture, will focus on the NServiceBus architecture. We will also discuss the different message and storage types supported in NSB. This discussion will include an introduction to some of the tools and advantages of using NSB as we conceptually look at how some of the pieces fit together. We will back up the discussions with code examples.

Chapter 3, Particular Service Platform, will focus on Particular Service Platform that includes ServicePulse, ServiceControl, ServiceInsight, and ServiceMatrix. As the name implies, ServicePulse gives us a pulse on the messages, services, and endpoints. ServiceControl is the control API that ServicePulse and ServiceInsight depend on to get their internal information. ServiceInsight gives us graphical and message-level drilldown into the services, endpoints, and messages that also include a saga drilldown. ServiceMatrix is the graphical interface into code generation for NServiceBus endpoints, services, and messages in a Visual Studio canvas.

Chapter 4, Knowing Your IBus, will discuss various configurations and examples of the NSB IBus. In Enterprise Service Bus (ESB), the bus is the backbone of the sagas, subscriptions, sending, timeouts, and gateways. For NServiceBus, the bus interface is known as the IBus. Knowing your IBus is the most important part of NServiceBus.

Chapter 5, Persistence Architecture, will cover persisting items to the database, including messages and logging. For the ESB bus, persistence is the key element for the storing of messages, which could be associated as business objects that run through the ESB workflow. The metadata comprises other persistent elements that define how the messages and workflow are being handled in the ESB through configuration. Persistence can also be considered the feedback that the ESB gives back to the system in the form of logging, errors, and audits.

Chapter 6, SQL Server Examples, will focus on snippets about SQL Server examples. We will discuss queuing in SQL Server. More advanced features for Entity Framework will be discussed, as will MVC-EF examples. This chapter is for developers who are working with SQL Server and Entity Frameworks with NServiceBus.

Chapter 7, Persistent Snippets, will focus on snippets about persistence. We will discuss NHibernate, RavenDB, and MongoDB. We will dive into code to accomplish some database tasks related to NServiceBus. This code could be applied to many tasks that are not ESB-specific. But this is a much needed chapter on database code itself. We will create SQL Server databases without the use of SQL code and read tables that NServiceBus created in RavenDB. We will show how to create tables with code, read tables, and display tables in NHibernate and RavenDB.

Chapter 8, The NSB Cloud, will focus on snippets about NServiceBus in the Azure cloud after an introduction to various components about the Azure cloud services. NSB has a lot of support for the Azure cloud. Be it SQL Storage, Azure Queues, or the Azure Service Bus, NSB is headed in a direction of working more with Cloud Services. We will briefly discuss Salesforce and even NSB integration into mobile devices.

What you need for this book

Beginner-level knowledge of Visual Studio 2012 with C# will be required. This could be the Visual Studio 2012 Express Edition from Microsoft.

Who this book is for

This book is for any person who wishes to develop, design, or architect NServiceBus's ESB systems in C# as a possible solution. We discuss many items that go beyond NSB, such as MVC-EF frameworks and databases such as RavenDB, SQL Server, and MongoDB.

Conventions

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: "First, run the Install commands for the pieces that are accomplished in PowerShell commandlets."

A block of code is set as follows:

using System;
using System.IO;
using ServiceControl.Plugin.CustomChecks;
using ServiceControl.Plugin.CustomChecks.Messages;
using ServiceControl.Plugin.CustomChecks.Internal;
namespace PaymentEngine.ECommerce
{
    public class MyCustomCheck : CustomCheck
    {
        public MyCustomCheck()
            : base("ECommerce SubmitPayment check", "ECommerce")
        {
            ReportPass();
        }
    }}

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

"PM> Get-NserviceBusLocalMachineSettings"

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Go to the Component Services option under the Administrative Tools menu."

Tip

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 through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

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 http://www.packtpub.com. If you purchased this book elsewhere, you can http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

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 http://www.packtpub.com/support, 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 to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

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.

Questions

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.