Microsoft SQL Server 2012 Bible
by Adam Jorgensen, Jorge Segarra, Patrick LeBlanc, Jose Chinchilla, Aaron Nelson
Configuring a Message Queue
Service Broker uses a messaging or dialog metaphor, but there's much more to Service Broker than just the messages. The Service Broker uses the following objects, which must be defined in the following order:
Other than defining the message type as XML and naming the objects, there isn't much complexity to setting up a Service Broker database. Although the messages don't have to be XML, they almost always will be. That's because the data definition language, or DDL, does all the work; and Service Broker is a message-agnostic work queue that serves as an infrastructure for the messages. There's more work in placing messages on and taking messages off the queue.
The first step to is to enable Service Broker on the database. Then create a Service Broker queue by defining a message type and a contract that uses that message type:
ALTER DATABASE AdventureWorks2012 SET ENABLE_BROKER; GO CREATE MESSAGE TYPE HelloWorldMessage VALIDATION = WELL_FORMED_XML ; GO CREATE CONTRACT HelloWorldContract ( HelloWorldMessage SENT BY INITIATOR); GO
The initiator and target queues are created using the CREATE ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access