Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Server Service Broker The South East Michigan SQL Server Users Group Tom Groszko

Similar presentations

Presentation on theme: "SQL Server Service Broker The South East Michigan SQL Server Users Group Tom Groszko"— Presentation transcript:

1 SQL Server Service Broker The South East Michigan SQL Server Users Group Tom Groszko


3 September 15-16, 2010

4 ` November 8-11, 2010 Seattle, Washington

5 Purpose and Objectives Provide an introduction to Service Broker What Service Broker can do Define Service Broker Terms Sample code

6 What Service Broker Can Do Native support for messaging and queuing applications –Conversations –Message ordering and coordination Build distributed applications –Workload balancing –N-tier applications Transactional asynchronous processing

7 What Service Broker Can Do Take advantage of Service Oriented Architecture (SOA) Workflow (WF) BizTalk Microsoft Message Queuing (MSMQ)

8 Service Broker Terms – Message Type A MESSAGE TYPE defines the name of a message and the validation that Service Broker performs on this message. Both sides of a conversation must define the same message types. –Validation NONEWhatever you want in the message body (stored as varbinary(max)) EMPTYThe message body must be null. WELL_FORMED_XMLThe body must contain well formed xml.

9 Service Broker Terms - Initiator An Initiator is the service that starts a conversation. (BEGIN DIALOG) A service can be both an Initiator and a Target but on different conversations.

10 Service Broker Terms - Target A Target is a service that accepts a conversation that was started by another service. A service can be both an Initiator and a Target but on different conversations.

11 Service Broker Terms - Contract A CONTRACT defines the message types used in a broker conversation and which party in the conversation can send them.

12 Service Broker Terms - Queue A QUEUE is where Service Broker stores messages. A QUEUE is a ‘hidden table’ and is a schema-owned object. Like any other table it can be placed on a file group. A QUEUE has a status that is –ONmessages can be added and removed –OFFmessages cannot be added or removed.

13 Service Broker Terms - Queue A QUEUE has an Activation Status that may identify the stored procedure to process messages in the queue and how many instances of the procedure may run concurrently. When a QUEUE is unavailable messages are held in a transmission queue for the database, sys.transmission_queue.

14 Service Broker Terms - Queue POISON_MESSAGE_HANDLING –ONThe default. The QUEUE will be disabled, STATUS = OFF, when there are five consecutive transaction rollbacks. –OFFThe QUEUE will not be disabled by service broker because of transaction rollbacks.

15 Service Broker Terms - Queue A QUEUE can be queried with SELECT. –To prevent locking the queue SELECT * FROM schema.queue WITH(NOLOCK); It cannot be modified with INSERT, UPDATE or DELETE statements.

16 Service Broker Terms - Service A SERVICE is a name for a specific task or set of tasks and is used to route messages to the correct QUEUE and enforce CONTRACT constraints. A SERVICE identifies a QUEUE and a list of CONTRACTs that the service uses.

17 Service Broker Terms - Route A ROUTE identifies which network address a Service Broker service is located on. Whenever you want your messages to leave the database they originate in, you need to provide a ROUTE. ROUTE is not covered in this presentation.

18 Environment Automatically installed beginning with SQL2005 Service Broker External Activator is available with SQL Server 2008 Feature Pack –Lets you move logic to receive and process messages from the server engine to an executable. 58A033D316E1&displaylang=en 58A033D316E1&displaylang=en The model database has Broker Enabled = false –CREATE DATABASE creates a database with Broker Enabled = true despite the model setting.

19 Message Performance The techniques you use for tuning other applications apply to tuning Service Broker applications Source Pro SQL Server 2008 Service Broker by Klause Aschenbrenner APress

20 Demo SQL Server event notifications –Sample code to process SQL Server event notifications The code will provide a history record for all DDL changes made on an SQL Server. (Quite a bit less than source code management) –Demonstrate how to RECEIVE messages Set processing Row by agonizing row Sending and Receiving messages –A explanation of the basic code to SEND and RECEIVE a message. An order application that sends a message to three different services which process them asynchronously and send back a reply. The Service Broker Application Template.

21 Additional Information Pro SQL Server 2008 Service Broker Klaus Aschenbrenner A brief guide to SQL Server Service Broker broker.aspx broker.aspx SQL Server: Service Broker Team Blog A simple secure dialog with transport certificates certificates.aspx certificates.aspx Announcing Service Broker External Activator 85a2-93563f3f8f0e 85a2-93563f3f8f0e Sample activated application Get Started With Using External Activator activator.aspx activator.aspx Service Broker: Performance and Scalability Techniques Service Broker Tutorials Building a Distributed Service Broker Application

22 Additional Information The Service Broker Alphabet Part 1 The Service Broker Alphabet Part 2 Async Lifestyle: Manage Your Tasks With Service Broker SQL Server Service Broker - An Introduction An-Introduction.htm An-Introduction.htm Writing an SSBS App When the Initiator and Target are on the Same Database the-Initiator-and-Target-are-on-the-Same-Database.htm the-Initiator-and-Target-are-on-the-Same-Database.htm Service Broker Troubleshooting Service Broker Wait Types

23 Questions

Download ppt "SQL Server Service Broker The South East Michigan SQL Server Users Group Tom Groszko"

Similar presentations

Ads by Google