647
CHAPTER
25
Asynchronous Messaging with
Service Broker
IN THIS CHAPTER
Using Message Multicast
Defi ning a Work Queue
Queuing Messages
Managing Dialogs
S
ervice 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 fl exibility,
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
notifi es customers that their order has been shipped. You can use Service Broker to send this mes-
sage 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 an asynchronous shipping notifi cation example using Service Broker.
c25.indd 647c25.indd 647 7/31/2012 9:21:35 AM7/31/2012 9:21:35 AM
http://www.it-ebooks.info