Mastering NServiceBus and Persistence
上QQ阅读APP看书,第一时间看更新

Chapter 2. The NServiceBus Architecture

In this chapter, we will focus on the NServiceBus architecture. We will 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. We will conceptually look at how some of the pieces fit together while backing up the discussions with code examples.

In this chapter, we will cover the following topics:

  • Benefits of NSB
    • More on endpoints
    • The application security perspective
  • Message exchange patterns
    • The publish/subscribe pattern
    • The request-response pattern
    • Saga services
    • Message mutations
    • Message encryption
    • Cluster messaging
    • Performance monitoring
    • Gateway messages
  • Storage patterns
    • Timeout storage
    • Subscription storage
    • Backing it up
  • Monitoring
    • A sample e-mail notification
  • Recap

NSB is the cornerstone of automation. As an Enterprise Service Bus (ESB), NSB is the most popular C# ESB solution. NSB is a framework that is used to provide many of the benefits of implementing a service-oriented architecture (SOA). It uses an IBus and its ESB bus to handle messages between NSB services, without having to create custom interaction. This type of messaging between endpoints creates the bus. The services, which are autonomous Windows processes, use both Windows and NSB hosting services. NSB-hosting services provide extra functionalities, such as creating endpoints; setting up Microsoft Queuing (MSMQ), DTC for transactions across queues, subscription storage for publish/subscribe message information, NSB sagas; and much more. Deploying these pieces for messaging manually can lead to errors and a lot of work is involved to get it correct. NSB takes care of provisioning its needed pieces.

NSB is not a frontend framework, such as Microsoft's Model-View-Controller (MVC). It is not used as an Object-to-Relationship Mapper (ORM), such as Microsoft's Entity Frameworks, to map objects to SQL Server tables. It is also not a web service framework, such as Microsoft's Windows Communication Foundation (WCF). NSB is a framework to provide the communication and support for services to communicate with each other and provide an end-to-end workflow to process all of these pieces.