Chapter 25

Asynchronous Messaging with Service Broker

In This Chapter

Using Message Multicast

Defining a Work Queue

Queuing Messages

Managing Dialogs

Service Broker is one of the most powerful features of SQL Server. This feature is essential in any Service-Oriented Architecture (SOA) data store architecture because it enables you to send asynchronous messaging and add work queues to a database to provide high flexibility, extensibility, and scalability.

If you've ever built a table to hold pending work, such as orders to be processed by a Material Resource Planning (MRP) system, then you've built a work queue. In one application, Service Broker is just that — a high-performance, wide-payload work queue manager integrated into SQL Server with DDL and monitoring capabilities, all rolled into one application.

For example, suppose that you want to pass sales order data to another database application that notifies customers that their order has been shipped. You can use Service Broker to send this message to another database where an e-mail message is queued to be sent out. The outgoing e-mails may have some sort of delay due to restrictions imposed by the e-mail provider. An independent process can manage e-mail transmissions without affecting the main sales database. You might also have a loosely coupled application in which communications cannot be guaranteed at all times. If data goes to a queue, it can be sent whenever the communications pipeline is open. Figure 25.1 illustrates ...

Get Microsoft SQL Server 2012 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.