O'Reilly logo

Microsoft® SQL Server® 2008 Bible by Uttam Parui, Mike White, Paul Nielsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 35. Asynchronous Messaging with Service Broker

IN THIS CHAPTER

  • Defining a work queue

  • Queuing messages

  • Managing conversations

Service Broker is a powerful yet simple work queue system that can be used to add asynchronous messaging and work queues to a database abstraction layer to provide high scalability, and it is essential in any SOA data store architecture.

If you've ever built a table to hold work to be done, such as orders to be processed by a Materials Requirement Planning system, then you've built a work queue. In one application Service Broker is just that—a high-performance, wide-payload work queue integrated into SQL Server with DDL and monitoring capabilities.

Service Broker can also be used to pass messages with guaranteed secure delivery between work queues, which opens up a world of possibilities.

Because Service Broker is essentially just a SQL Server table, it includes all the cool transactional and back-up capabilities inherent to SQL Server. This is what sets Service Broker apart from other queuing technologies, such as Microsoft Message Queuing (MSMQ).

The queue contains a single, wide column for the message body, which is OK because the message will typically contain a single XML file or fragment or SOAP message as the payload.

Service Broker is not enabled by default so the first specific step to working with Service Broker is to turn it on using the ALTER DATABASE command:

ALTER DATABASE AdventureWorks SET ENABLE_BROKER;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required