starting with sQL server 2005, the sQL service Broker ssB has been included within the database platform.. sQL service Broker, like all message queuing technologies, allows for asynchron
Trang 1SQL Server XML Support • Chapter 11 517 Self Test Quick Answer Key
1 D
2 C
3 A
4 B
5 C
6 C
7 C
8 D
9 D
10 B
11 C
12 B
13 A
14 A
15 D
16 D
17 A
18 B
19 D
20 D
Trang 2This page intentionally left blank
Trang 3Exam objectives review:
˛ Exam Objectives Fast Track
˛ Exam Objectives Frequently Asked Questions
˛ Self Test
˛ Self Test Quick Answer Key
Exam objectives in this chapter:
The Queuing Concept Explained
■
■
Service Broker Defined
■
■
Message Types
■
■
Contracts
■
■
Queues
■
■
Services
■
■
Routes
■
■
Sending a Message
■
■
Service Broker
Chapter 12
MCTS SQL Server 2008
Exam 432
Trang 4520 Chapter 12 • Service Broker
Introduction
This chapter will introduce the DBA to service Broker it will explain what service Broker is, how to set it up, and how to test to be sure it’s
functioning it will also educate the DBA on some of the uses for service Broker service Broker is commonly used for asynchronous tasks
The concept of messages and queues is explained in this chapter, along with contracts and message types
The Queuing Concept Explained
The concept of message queuing has been around for many years Microsoft has included message queuing as an available option within the operating system since Windows NT 4.0 starting with sQL server 2005, the sQL service Broker (ssB) has been included within the database platform sQL service Broker, like all message queuing technologies, allows for asynchronous messages to be sent from one server to another with the receiving server processing that message and carrying out some predefined task
A simple analogy is that one process within sQL server is going to send an e-mail to another process within sQL server The second process will read the message and do something based on the contents of that message The beauty of sQL service Broker is that the something that it does is totally up to the developer of the stored procedure that is going to be run
The beauty of message queuing in general is that message delivery is guaranteed
in the order sent, as is the fact that a message can be received only once What this means is that no matter how many people are sending messages to the receiving system the messages will always be processed in the correct order that they were sent, and the receiving system can receive them once and only once This will prevent the system from reprocessing the same message twice and causing errors because of processing the same message twice The only way a message can be processed twice would be if the sending system sent the same message text as two separate messages
Whereas other messaging systems like Microsoft Message Queue (MsMQ) can
be accessed directly by Windows applications or applications on other operating systems, sQL service Broker does not currently support this in order to send or receive a message you have to log in to the sQL server database Neither Microsoft nor any third party as of this writing has written a way to send or receive messages without connecting to the sQL server database Because of this, sQL service Broker may not always be the correct solution for your messaging
Trang 5Service Broker • Chapter 12 521
environment if the messages are not going to be sent or received by T/sQL then
sQL service Broker may not be your best option
Service Broker Defined
There are two main concepts within sQL service Broker: sending and
receiving messages Any process can send a message, provided it has the required
rights to do so Messages can be received on demand—for example, through a sQL
server job performing a RECEIVE command on the queue or by a Windows
application logging into the database and performing a RECEIVE command on
the queue Messages can also be received and processed automatically by using what
is called an activated stored procedure The activated stored procedure is a normal
stored procedure that is started automatically by the receiving queue when a
message is received The procedure would then receive the message and process
the contents of the message as needed (we will examine this more closely later in
the chapter)
Any database within the sQL server instance can use the sQL service
Broker including the system databases it is recommended, however, that you not make any changes to the sQL service Broker within the system databases
because sQL server uses the service Broker for its own tasks in fact, even if
you have never used sQL service Broker before, if you use sQL Mail to
send e-mails from the sQL server you are using sQL service Broker, because
sQL Mail uses the service Broker to queue the messages for sending
The sQL service Broker is a collection of objects within the database
that when configured can be used to send messages from one process to another
These messages can be sent within the same database, to another database within
the same instance of sQL server, to another database in another sQL server
instance on the same server, or to another sQL server instance on another server
either within your company’s network or to another company’s network
There are a few Dynamic Management views (DMvs) that are used to gauge the health and performance of the service Broker system of these the most
important when troubleshooting sQL server Broker issues are the
sys.conver-sation_endpoints and the sys.transmission_queue The sys.conversys.conver-sation_endpoints is
used most often to troubleshoot issues when sending messages from one queue to
another within the same database; the sys.transmission_queue is used most often to
troubleshoot issues when sending messages from one database to another With
regard to the sQL service Broker it is important to remember that when we
speak of sending messages from one database we are talking about sending messages
within the instance of sQL server or across servers