SQL Server 2005 for Developers David Truxall NuSoft Solutions Drew Robbins Microsoft Corporation
Agenda XML Enhancements  CLR in SQL Server  Service Broker
XML in the Database Overview XML has become widely adopted XML is ubiquitous, extensible, and a platform independent transport format Supports structured and semi-structured data Limited support in SQL Server 2000 First class support in SQL Server 2005
XML In the Database Business Opportunity The majority of all data transmitted electronically between organizations is now in XML.  By storing XML natively, SQL Server 2005 helps eliminate the friction of data transfer between organizations. With the improved XML support in VS 2005, building e-business applications is radically simplified.
XML in the Database XML Data Type SQL Server 2005 adds native XML storage with XML data type Stores both well-formed and validated XML Implementation Markup documents Tree-structured data where re-assembly costs should be minimal Semi-structured data
XML in the Database XML Data Type An alternative to storing XML on disk Supports column, variable, or parameter Can represent Version 1.0 documents or fragments Methods on XML data type query(), value(), exist(), modify(), and nodes()
XML in the Database XML Schema Support Validation and typing provided by XSD W3C recommendation Mechanism for type definitions Validation constraints Typed Data Guarantees the  shape  of the data Allows storage and query optimizations
XML in the Database XML Schema Collections Creating an XML Schema Collection CREATE XML SCHEMA COLLECTION ResumeSchema AS '<xs:schema  targetNameSpace='http://schemas.ms.com/emp&quot; …/>' Constraining XML documents CREATE TABLE Employee (..., Resume XML(ResumeSchema)) Retrieving XML Schema Collections SELECT Name FROM AdventureWorks.sys.xml_schema_collections
XML Data Type
XML in the Database XML Indexes Create XML index on XML column CREATE PRIMARY XML INDEX IDX1 ON JobCandidate (Resume) Creates a secondary, B-tree index on Path, Property, or Value Speeds up queries Results can be served directly from index Uses SQL Server's cost based optimizer Full-Text Indexing/Searching supports XML
XML in the Database XML Indexes PATH Index When querying by path and value /ItemList/Item[@ProductID=&quot;1&quot;] PROPERTY Index When retrieving node values by path (/ItemList/Item/@ProductID)[1] VALUE Index When querying imprecisely, like for existence //Item[@ProductID=&quot;1&quot;]
XML in the Database XML Indexes Requirements A clustered PK must exist in the table If XML index exists, the PK may not be altered Only one primary XML index per column Many secondary XML indexes per column PATH, PROPERTY, and VALUE All index names must be unique per table
XML in the Database XQuery Query XML documents and data Based on W3C working draft FLWOR - For, Let, Where, Order by, Return XQuery methods .query() – returns XML data type instance .value() – returns a single (scalar) value .exist() – returns 1 if expression returns item(s) .nodes() – returns a row per selected node
XML in the Database XML Data Manipulation Language Inefficient to UPDATE the entire column XML sub-tree modification using  .modify() Three actions:  Insert ,  Delete , or  Replace UPDATE xmlTable SET xmlColumn.modify('insert  <section num=&quot;2&quot;> <heading>Background</heading> </section> after (/doc/section[@num=1])[1]')
XQuery
XML in the Database FOR XML Improvements Support for XSD schemas Support for NULL values Support for XML data type Nested FOR XML Can be assigned to an XML data type FOR XML PATH
CLR in the Database Overview Enhanced programming model Enhanced safety and security User defined types and aggregates Common development environment Performance and scalability
CLR in the Database Business Opportunity Leverage .NET productivity and the BCL Better way to encapsulate your IP A new world of ways to extend SQL Server User-defined types to fit your domain User-defined aggregates to fit your domain Go over the wall you hit with T-SQL Replace Extended Procedures (XPs)
CLR in the Database Architecture Common Language Runtime (CLR) Assemblies Can write stored procedures, triggers, UD functions, UD types, and aggregate functions Any CLR language Great replacement for Extended Stored Procedures (XPs) Supported in SQL Express
CLR in the Database Microsoft® SQL Server™ Runtime hosted inside SQL Microsoft® Visual Studio® .NET Project VB, C# SQL Queries:  select sum( tax(sal,state)  )  from Emp where county = ‘King’ Assembly: “TaxLib.dll” build SQL Data Definition:  create assembly …  create function …  create procedure …  create trigger …  create type … deploy
CLR in the Database Security Managed Code running in CLR Type safety, application domains, CAS More secure than XPs Reliability and safety design goals User code can't compromise SQL engine User code can't overwrite SQL engine memory buffers or internal data structures User code must be authenticated and authorized before being allowed access
CLR in the Database Security Permission Sets SAFE EXTERNAL_ACCESS UNSAFE
CLR in the Database T-SQL or Managed Code? T-SQL is superior when Code mostly performs data access Code has little or no procedural logic Managed Code is superior when Code has CPU-intensive methods Code has complex logic Code can make use of the .NET BCL
CLR in the Database Managed Database Objects X Aggregate Functions X User Defined Types X X User Defined Functions X X Triggers X X Stored Procedures .NET (SQL 2005) T-SQL (SQL 2000)
CLR in the Database Managed Stored Procedures Stored Procedures Public, static methods on a class Returns a void or int SqlPipe.Execute() and SqlPipe.Send()  public static void ExecuteToClient()  { SqlConnection conn =  new  SqlConnection(&quot;context connection=true&quot;); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = &quot;select @@version&quot;; SqlContext.GetPipe().Execute(cmd); }
CLR in the Database Managed Triggers Triggers Similar to stored procedures Determine which columns have been modified Reference INSERTED and DELETED tables SqlConnection conn =  new  SqlConnection(&quot;context connection=true&quot;); sqlCommand sqlComm = conn.CreateCommand() sqlComm.CommandText = &quot;SELECT column_1 from INSERTED&quot;;
CLR in the Database Managed User Defined Functions Two types of User Defined Functions Scalar-valued function (SVF) Returns a single value, such as string or integer Class methods determine return type Table-valued function (TVF) Data returned through an ISqlReader object public static ISqlReader ReadLog(String logname) { return (ISqlReader)new MySqlReader(logname); }
CLR in the Database Managed User Defined Types When the built-in SQL Server types won't do Create custom, complex structured types Benefits Strong encapsulation (both at client and server) Deep integration support with SQL Server Requirements SqlUserDefinedTypeAttribute, Serializable, INullable, Parse(), ToString() Read() and Write() to support custom serialization Others
CLR in the Database Managed Aggregate Functions Perform a calculation on a set of values and return a single value, such as SUM or MAX SqlUserDefinedAttribute Must implement these methods so the Query Processor can use your aggregate function Init(), Accumulate(), Merge(), Terminate()
CLR in the Database Assemblies .NET Assemblies Self-describing, metadata, dependencies Unit of deployment, CLR permission grants, versioning, etc. Stored in database CREATE, ALTER, DROP DDL CREATE ASSEMBLY FinanceFunctions FROM 'c:\code\FinanceFunctions.dll' WITH PERMISSION_SET = SAFE
CLR in the Database
Service Broker Overview Service Broker adds asynchronous, distributed, and decoupled environment Fully integrated into database engine New set of SQL Server objects (DDL & DML) Integrated management and deployment Custom solutions and benefits Generalized asynchronous semantics Inter and intra-instance queuing Distributed transactions not required Multi-threading in stored procedures
Service Broker Business Opportunity Don't call us, we'll call you Asynch can result in faster applications Asynch can smooth out connectivity bugs Notifications can help w/ middle-tier or client caching of data Leverage Message Queue architecture Shares Begin/End patterns with .NET
Service Broker Asynchronous Architecture Loose coupling Load distribution Batch processing Performance Scale out
Service Broker Order Entry Data Flow Diagram
Service Broker Features Database objects and DML statements that enable asynchronous messaging operations Queues, Message Types, Contracts, Services “ BEGIN DIALOG”, “SEND”, “RECEIVE” Fully integrated into the database engine Single Programming Model Local Transactions Integrated Management and Deployment
Service Broker Both the client & stored procedure run in:  Same Transaction Same Security Context Same Thread of Execution Client App SQL Engine Stored Proc Without Service Broker Transaction
Service Broker Client App Launched Stored Proc Stored proc runs on: Different transaction Different thread Different security Different time With Service Broker Transaction Transaction Persisted Dialog
Service Broker Dialogs Two-way Messaging “Dialogs” Exactly-once, In-order Reliable delivery to local and remote queues Large Message Fragmentation APP 1 SQL Engine SQL Engine APP 2
Service Broker New Commands CREATE MESSAGE TYPE CREATE CONTRACT CREATE QUEUE CREATE SERVICE ALTER SERVICE ALTER MESSAGE TYPE  ALTER QUEUE ALTER CONTRACT DROP MESSAGE TYPE DROP CONTRACT DROP QUEUE DROP SERVICE CREATE ROUTE ALTER ROUTE DROP ROUTE New DDL BEGIN DIALOG CONVERSATION END CONVERSATION MOVE CONVERSATION GET SERVICE INSTANCE RECEIVE SEND BEGIN DIALOG TIMER New DML
Service Broker Impact on Performance Shipping as trigger during Order Shipping queued by trigger during Order
Service Broker Demo Scenario OrderService ShippingService AccountsService NewOrder
Service Broker
Call To Action Leverage SQL Server 2005 to connect with applications and partners using the ubiquitous XML format. Be smart about building functionality using CLR in SQL Server. Leverage the Service Broker to create loosely-coupled message queues for your applications.
Call To Action http://www.chrysalisevents.com/vs2005devcon/ Detroit – June 16
© 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.

More Related Content

PPT
Marmagna desai
PPT
Tech Days09 Sqldev
PPT
SQL Server 2008 for Developers
PPTX
SQL, Embedded SQL, Dynamic SQL and SQLJ
PPTX
ADO.NET by ASP.NET Development Company in india
PDF
Using T-SQL
PPTX
MS SQL SERVER: Programming sql server data mining
PDF
Oracle SQL Basics
Marmagna desai
Tech Days09 Sqldev
SQL Server 2008 for Developers
SQL, Embedded SQL, Dynamic SQL and SQLJ
ADO.NET by ASP.NET Development Company in india
Using T-SQL
MS SQL SERVER: Programming sql server data mining
Oracle SQL Basics

What's hot (20)

PPT
Ado.net
PPTX
Ch06 ado.net fundamentals
PPT
For Beginers - ADO.Net
PPTX
Design Concepts For Xml Applications That Will Perform
PPT
ASP.NET Session 11 12
DOC
Oracle notes
PPTX
Ado .net
PDF
Introduction and overview ArangoDB query language AQL
PPT
ADO.NET
PPTX
Getting started with entity framework
PPTX
Chapter 3: ado.net
PPTX
ADO.NET -database connection
PPT
Ado.net
DOC
Oracle vs. MS SQL Server
PPTX
Ch 7 data binding
PPTX
Ordina Oracle Open World
PDF
An introduction into Oracle Enterprise Manager Cloud Control 12c Release 3
PPT
Jdbc 4.0 New Features And Enhancements
PPTX
For Beginners - Ado.net
PPT
ADO .Net
Ado.net
Ch06 ado.net fundamentals
For Beginers - ADO.Net
Design Concepts For Xml Applications That Will Perform
ASP.NET Session 11 12
Oracle notes
Ado .net
Introduction and overview ArangoDB query language AQL
ADO.NET
Getting started with entity framework
Chapter 3: ado.net
ADO.NET -database connection
Ado.net
Oracle vs. MS SQL Server
Ch 7 data binding
Ordina Oracle Open World
An introduction into Oracle Enterprise Manager Cloud Control 12c Release 3
Jdbc 4.0 New Features And Enhancements
For Beginners - Ado.net
ADO .Net
Ad

Similar to Sql Summit Clr, Service Broker And Xml (20)

PPT
SQL Server 2008 for Developers
PPT
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
PPTX
Dev Sql Beyond Relational
PPT
Dr. Jekyll and Mr. Hyde
PPT
SQLCLR For DBAs and Developers
PPT
SQL Server 2008 for .NET Developers
PPTX
PPT
Ms sql server architecture
PPT
Module02
PPT
Windows Azure and a little SQL Data Services
PPTX
Introducing SOA and Oracle SOA Suite 11g for Database Professionals
PPTX
PPTX
Introducing U-SQL (SQLPASS 2016)
PPT
Introduction to Threading in .Net
PPT
What's New for Developers in SQL Server 2008?
PPT
SQL Server 2008 Overview
PPT
Saying goodbye to SQL Server 2000
PPTX
Sql database development part 1
PDF
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
PDF
treeview
SQL Server 2008 for Developers
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Dev Sql Beyond Relational
Dr. Jekyll and Mr. Hyde
SQLCLR For DBAs and Developers
SQL Server 2008 for .NET Developers
Ms sql server architecture
Module02
Windows Azure and a little SQL Data Services
Introducing SOA and Oracle SOA Suite 11g for Database Professionals
Introducing U-SQL (SQLPASS 2016)
Introduction to Threading in .Net
What's New for Developers in SQL Server 2008?
SQL Server 2008 Overview
Saying goodbye to SQL Server 2000
Sql database development part 1
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
treeview
Ad

More from David Truxall (9)

PDF
iOS for Android Developers (with Swift)
PDF
Consuming Web Services in Android
PPT
Day Of Dot Net Ann Arbor 2008
PPT
Advanced Visual Studio 2005 Tools For Office Programming And Deployment
PPT
Visual Studio 2005 Database Professional Edition
PPT
Visual Studio 2005 New Features
PPT
ADO.Net Improvements in .Net 2.0
PPT
Windows Communication Foundation
PPT
Day Of Dot Net Ann Arbor 2007
iOS for Android Developers (with Swift)
Consuming Web Services in Android
Day Of Dot Net Ann Arbor 2008
Advanced Visual Studio 2005 Tools For Office Programming And Deployment
Visual Studio 2005 Database Professional Edition
Visual Studio 2005 New Features
ADO.Net Improvements in .Net 2.0
Windows Communication Foundation
Day Of Dot Net Ann Arbor 2007

Recently uploaded (20)

PPT
Overviiew on Intellectual property right
PDF
Be ready for tomorrow’s needs with a longer-lasting, higher-performing PC
PDF
Advancements in abstractive text summarization: a deep learning approach
PDF
The Basics of Artificial Intelligence - Understanding the Key Concepts and Te...
PDF
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
PDF
Introduction to c language from lecture slides
PPTX
maintenance powerrpoint for adaprive and preventive
PPTX
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
PDF
Child-friendly e-learning for artificial intelligence education in Indonesia:...
PDF
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
PDF
Human Computer Interaction Miterm Lesson
PDF
Secure Java Applications against Quantum Threats
PDF
Examining Bias in AI Generated News Content.pdf
PDF
Decision Optimization - From Theory to Practice
PDF
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
PDF
State of AI in Business 2025 - MIT NANDA
PPTX
Report in SIP_Distance_Learning_Technology_Impact.pptx
PDF
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
ment.tech-How to Develop an AI Agent Healthcare App like Sully AI (1).pdf
Overviiew on Intellectual property right
Be ready for tomorrow’s needs with a longer-lasting, higher-performing PC
Advancements in abstractive text summarization: a deep learning approach
The Basics of Artificial Intelligence - Understanding the Key Concepts and Te...
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
Introduction to c language from lecture slides
maintenance powerrpoint for adaprive and preventive
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
Child-friendly e-learning for artificial intelligence education in Indonesia:...
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
Human Computer Interaction Miterm Lesson
Secure Java Applications against Quantum Threats
Examining Bias in AI Generated News Content.pdf
Decision Optimization - From Theory to Practice
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
State of AI in Business 2025 - MIT NANDA
Report in SIP_Distance_Learning_Technology_Impact.pptx
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
ment.tech-How to Develop an AI Agent Healthcare App like Sully AI (1).pdf

Sql Summit Clr, Service Broker And Xml

  • 1.  
  • 2. SQL Server 2005 for Developers David Truxall NuSoft Solutions Drew Robbins Microsoft Corporation
  • 3. Agenda XML Enhancements CLR in SQL Server Service Broker
  • 4. XML in the Database Overview XML has become widely adopted XML is ubiquitous, extensible, and a platform independent transport format Supports structured and semi-structured data Limited support in SQL Server 2000 First class support in SQL Server 2005
  • 5. XML In the Database Business Opportunity The majority of all data transmitted electronically between organizations is now in XML. By storing XML natively, SQL Server 2005 helps eliminate the friction of data transfer between organizations. With the improved XML support in VS 2005, building e-business applications is radically simplified.
  • 6. XML in the Database XML Data Type SQL Server 2005 adds native XML storage with XML data type Stores both well-formed and validated XML Implementation Markup documents Tree-structured data where re-assembly costs should be minimal Semi-structured data
  • 7. XML in the Database XML Data Type An alternative to storing XML on disk Supports column, variable, or parameter Can represent Version 1.0 documents or fragments Methods on XML data type query(), value(), exist(), modify(), and nodes()
  • 8. XML in the Database XML Schema Support Validation and typing provided by XSD W3C recommendation Mechanism for type definitions Validation constraints Typed Data Guarantees the shape of the data Allows storage and query optimizations
  • 9. XML in the Database XML Schema Collections Creating an XML Schema Collection CREATE XML SCHEMA COLLECTION ResumeSchema AS '<xs:schema targetNameSpace='http://schemas.ms.com/emp&quot; …/>' Constraining XML documents CREATE TABLE Employee (..., Resume XML(ResumeSchema)) Retrieving XML Schema Collections SELECT Name FROM AdventureWorks.sys.xml_schema_collections
  • 11. XML in the Database XML Indexes Create XML index on XML column CREATE PRIMARY XML INDEX IDX1 ON JobCandidate (Resume) Creates a secondary, B-tree index on Path, Property, or Value Speeds up queries Results can be served directly from index Uses SQL Server's cost based optimizer Full-Text Indexing/Searching supports XML
  • 12. XML in the Database XML Indexes PATH Index When querying by path and value /ItemList/Item[@ProductID=&quot;1&quot;] PROPERTY Index When retrieving node values by path (/ItemList/Item/@ProductID)[1] VALUE Index When querying imprecisely, like for existence //Item[@ProductID=&quot;1&quot;]
  • 13. XML in the Database XML Indexes Requirements A clustered PK must exist in the table If XML index exists, the PK may not be altered Only one primary XML index per column Many secondary XML indexes per column PATH, PROPERTY, and VALUE All index names must be unique per table
  • 14. XML in the Database XQuery Query XML documents and data Based on W3C working draft FLWOR - For, Let, Where, Order by, Return XQuery methods .query() – returns XML data type instance .value() – returns a single (scalar) value .exist() – returns 1 if expression returns item(s) .nodes() – returns a row per selected node
  • 15. XML in the Database XML Data Manipulation Language Inefficient to UPDATE the entire column XML sub-tree modification using .modify() Three actions: Insert , Delete , or Replace UPDATE xmlTable SET xmlColumn.modify('insert <section num=&quot;2&quot;> <heading>Background</heading> </section> after (/doc/section[@num=1])[1]')
  • 17. XML in the Database FOR XML Improvements Support for XSD schemas Support for NULL values Support for XML data type Nested FOR XML Can be assigned to an XML data type FOR XML PATH
  • 18. CLR in the Database Overview Enhanced programming model Enhanced safety and security User defined types and aggregates Common development environment Performance and scalability
  • 19. CLR in the Database Business Opportunity Leverage .NET productivity and the BCL Better way to encapsulate your IP A new world of ways to extend SQL Server User-defined types to fit your domain User-defined aggregates to fit your domain Go over the wall you hit with T-SQL Replace Extended Procedures (XPs)
  • 20. CLR in the Database Architecture Common Language Runtime (CLR) Assemblies Can write stored procedures, triggers, UD functions, UD types, and aggregate functions Any CLR language Great replacement for Extended Stored Procedures (XPs) Supported in SQL Express
  • 21. CLR in the Database Microsoft® SQL Server™ Runtime hosted inside SQL Microsoft® Visual Studio® .NET Project VB, C# SQL Queries: select sum( tax(sal,state) ) from Emp where county = ‘King’ Assembly: “TaxLib.dll” build SQL Data Definition: create assembly … create function … create procedure … create trigger … create type … deploy
  • 22. CLR in the Database Security Managed Code running in CLR Type safety, application domains, CAS More secure than XPs Reliability and safety design goals User code can't compromise SQL engine User code can't overwrite SQL engine memory buffers or internal data structures User code must be authenticated and authorized before being allowed access
  • 23. CLR in the Database Security Permission Sets SAFE EXTERNAL_ACCESS UNSAFE
  • 24. CLR in the Database T-SQL or Managed Code? T-SQL is superior when Code mostly performs data access Code has little or no procedural logic Managed Code is superior when Code has CPU-intensive methods Code has complex logic Code can make use of the .NET BCL
  • 25. CLR in the Database Managed Database Objects X Aggregate Functions X User Defined Types X X User Defined Functions X X Triggers X X Stored Procedures .NET (SQL 2005) T-SQL (SQL 2000)
  • 26. CLR in the Database Managed Stored Procedures Stored Procedures Public, static methods on a class Returns a void or int SqlPipe.Execute() and SqlPipe.Send() public static void ExecuteToClient() { SqlConnection conn = new SqlConnection(&quot;context connection=true&quot;); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = &quot;select @@version&quot;; SqlContext.GetPipe().Execute(cmd); }
  • 27. CLR in the Database Managed Triggers Triggers Similar to stored procedures Determine which columns have been modified Reference INSERTED and DELETED tables SqlConnection conn = new SqlConnection(&quot;context connection=true&quot;); sqlCommand sqlComm = conn.CreateCommand() sqlComm.CommandText = &quot;SELECT column_1 from INSERTED&quot;;
  • 28. CLR in the Database Managed User Defined Functions Two types of User Defined Functions Scalar-valued function (SVF) Returns a single value, such as string or integer Class methods determine return type Table-valued function (TVF) Data returned through an ISqlReader object public static ISqlReader ReadLog(String logname) { return (ISqlReader)new MySqlReader(logname); }
  • 29. CLR in the Database Managed User Defined Types When the built-in SQL Server types won't do Create custom, complex structured types Benefits Strong encapsulation (both at client and server) Deep integration support with SQL Server Requirements SqlUserDefinedTypeAttribute, Serializable, INullable, Parse(), ToString() Read() and Write() to support custom serialization Others
  • 30. CLR in the Database Managed Aggregate Functions Perform a calculation on a set of values and return a single value, such as SUM or MAX SqlUserDefinedAttribute Must implement these methods so the Query Processor can use your aggregate function Init(), Accumulate(), Merge(), Terminate()
  • 31. CLR in the Database Assemblies .NET Assemblies Self-describing, metadata, dependencies Unit of deployment, CLR permission grants, versioning, etc. Stored in database CREATE, ALTER, DROP DDL CREATE ASSEMBLY FinanceFunctions FROM 'c:\code\FinanceFunctions.dll' WITH PERMISSION_SET = SAFE
  • 32. CLR in the Database
  • 33. Service Broker Overview Service Broker adds asynchronous, distributed, and decoupled environment Fully integrated into database engine New set of SQL Server objects (DDL & DML) Integrated management and deployment Custom solutions and benefits Generalized asynchronous semantics Inter and intra-instance queuing Distributed transactions not required Multi-threading in stored procedures
  • 34. Service Broker Business Opportunity Don't call us, we'll call you Asynch can result in faster applications Asynch can smooth out connectivity bugs Notifications can help w/ middle-tier or client caching of data Leverage Message Queue architecture Shares Begin/End patterns with .NET
  • 35. Service Broker Asynchronous Architecture Loose coupling Load distribution Batch processing Performance Scale out
  • 36. Service Broker Order Entry Data Flow Diagram
  • 37. Service Broker Features Database objects and DML statements that enable asynchronous messaging operations Queues, Message Types, Contracts, Services “ BEGIN DIALOG”, “SEND”, “RECEIVE” Fully integrated into the database engine Single Programming Model Local Transactions Integrated Management and Deployment
  • 38. Service Broker Both the client & stored procedure run in: Same Transaction Same Security Context Same Thread of Execution Client App SQL Engine Stored Proc Without Service Broker Transaction
  • 39. Service Broker Client App Launched Stored Proc Stored proc runs on: Different transaction Different thread Different security Different time With Service Broker Transaction Transaction Persisted Dialog
  • 40. Service Broker Dialogs Two-way Messaging “Dialogs” Exactly-once, In-order Reliable delivery to local and remote queues Large Message Fragmentation APP 1 SQL Engine SQL Engine APP 2
  • 41. Service Broker New Commands CREATE MESSAGE TYPE CREATE CONTRACT CREATE QUEUE CREATE SERVICE ALTER SERVICE ALTER MESSAGE TYPE ALTER QUEUE ALTER CONTRACT DROP MESSAGE TYPE DROP CONTRACT DROP QUEUE DROP SERVICE CREATE ROUTE ALTER ROUTE DROP ROUTE New DDL BEGIN DIALOG CONVERSATION END CONVERSATION MOVE CONVERSATION GET SERVICE INSTANCE RECEIVE SEND BEGIN DIALOG TIMER New DML
  • 42. Service Broker Impact on Performance Shipping as trigger during Order Shipping queued by trigger during Order
  • 43. Service Broker Demo Scenario OrderService ShippingService AccountsService NewOrder
  • 45. Call To Action Leverage SQL Server 2005 to connect with applications and partners using the ubiquitous XML format. Be smart about building functionality using CLR in SQL Server. Leverage the Service Broker to create loosely-coupled message queues for your applications.
  • 46. Call To Action http://www.chrysalisevents.com/vs2005devcon/ Detroit – June 16
  • 47. © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.