SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Querying and Managing Data Using SQL Server 2005
Objectives


                In this session, you will learn to:
                   Appreciate message-based communication
                   Implement Service Broker




     Ver. 1.0                        Session 18             Slide 1 of 14
Querying and Managing Data Using SQL Server 2005
Introduction to Service Broker


                •   Flash presentation: Implementing Service Broker




     Ver. 1.0                          Session 18                     Slide 2 of 14
Querying and Managing Data Using SQL Server 2005
Introduction to Service Broker Conversation Process


                Is explained by the following diagram.




     Ver. 1.0                      Session 18            Slide 3 of 14
Querying and Managing Data Using SQL Server 2005
Just a minute


                Which of the following objects processes a message from a
                queue?
                1. Service
                2. Service program
                3. Contract




                Answer:
                1. Service program




     Ver. 1.0                        Session 18                    Slide 4 of 14
Querying and Managing Data Using SQL Server 2005
Creating Messages


                    Message:
                       Is an entity that is exchanged between the Service Broker
                       services
                       Can contain a validation over the datatype that a message
                       possesses
                       Is of a specific message type
                •   Message Type:
                       Can be created by using the CREATE MESSAGE TYPE
                       command
                       Syntax:
                        CREATE MESSAGE TYPE message_type_name
                        [ VALIDATION = { NONE | EMPTY |
                        WELL_FORMED_XML | VALID_XML WITH SCHEMA
                        COLLECTION schema_collection_name } ] [ ; ]
                    Let’s see how…




     Ver. 1.0                           Session 18                           Slide 5 of 14
Querying and Managing Data Using SQL Server 2005
Creating Queues


                Queue:
                   Is an object that stores the messages
                   Can be viewed like a pipeline for messages
                   Is created by using the CREATE QUEUE command
                   Syntax:
                    CREATE QUEUE <object> [ WITH [ STATUS = { ON
                    | OFF } [ , ] ] [ RETENTION = { ON | OFF }
                    [ , ] ] [ ACTIVATION ( [ STATUS = { ON |
                    OFF } , ] PROCEDURE_NAME = <procedure> ,
                    MAX_QUEUE_READERS = max_readers , EXECUTE AS
                    { SELF | 'user_name' | OWNER } ) ] ]
                Let’s see how…




     Ver. 1.0                    Session 18                Slide 6 of 14
Querying and Managing Data Using SQL Server 2005
Creating Contracts


                Contract:
                   Is an agreement between two services that need to
                   communicate with each other
                   Specifies the type of message that will be used in a
                   conversation
                   Is created by using the CREATE CONTRACT command
                   Syntax:
                     CREATE CONTRACT contract_name
                     [ AUTHORIZATION owner_name ]
                     ( { { message_type_name | [ DEFAULT ] }
                     SENT BY { INITIATOR | TARGET | ANY } }
                        [ ,...n] ) [ ; ]
                Let’s see how…



     Ver. 1.0                      Session 18                         Slide 7 of 14
Querying and Managing Data Using SQL Server 2005
Creating Services


                Service:
                   Is used by the Service Broker to deliver messages to the
                   correct queue within a database
                   Is used to route messages, to enforce the contract for a
                   conversation, and to determine the remote security for a new
                   conversation
                   Is created by using the CREATE SERVICE command
                   Syntax:
                      CREATE SERVICE service_name
                      [ AUTHORIZATION owner_name ] ON
                      QUEUE
                      [ schema_name. ]queue_name [ (
                      contract_name | [DEFAULT] [ ,...n ] ) ]
                      [ ; ]
                Let’s see how…
     Ver. 1.0                       Session 18                           Slide 8 of 14
Querying and Managing Data Using SQL Server 2005
Beginning a Conversation


                Services communicate through a dialog.
                Conversation can begin using the BEGIN DIALOG
                command.
                Syntax:
                    BEGIN DIALOG [ CONVERSATION ]
                    @dialog_handle FROM SERVICE
                initiator_service_name
                    TO SERVICE 'target_service_name']
                    [ ON CONTRACT contract_name ]
                Let’s see how…




     Ver. 1.0                    Session 18                     Slide 9 of 14
Querying and Managing Data Using SQL Server 2005
Sending and Receiving Messages


                •   Messages are sent using the SEND ON CONVERSATION
                    command.
                •   Syntax:
                    SEND ON CONVERSATION conversation_handle
                    [ MESSAGE TYPE message_type_name ]
                    [ ( message_body_expression ) ] [ ; ]
                    Let’s see how…




     Ver. 1.0                        Session 18                  Slide 10 of 14
Querying and Managing Data Using SQL Server 2005
Demo: Implementing Service Broker


                Problem Statement:
                   The management of AdventureWorks, Inc. wants to know the
                   exact yearly sales at any point of the year to help them plan
                   future strategies. The aggregated yearly sales data is maintained
                   in the SalesDetails table of the SalesDB database.
                   The sales transaction details are stored in the SalesOrderHeader
                   and SalesOrderDetails tables in the AdventureWorks database.
                   To keep the yearly sales data updated, you need to ensure that
                   whenever any order is processed and its shipping date is
                   updated in the AdventureWorks database, the total monetary
                   value of that order, stored in the SubTotal column of the table,
                   should be added to the total yearly sales in the SalesDB
                   database.




     Ver. 1.0                       Session 18                           Slide 11 of 14
Querying and Managing Data Using SQL Server 2005
Demo: Implementing Service Broker


                Solution:
                   To solve the preceding problem, you need to perform the
                   following tasks:
                     1.   Create a service program.
                     2.   Create message types, contract, queues, and service objects.
                     3.   Create a trigger on the SalesOrderHeader table.
                     4.   Verify the functionality.




     Ver. 1.0                           Session 18                               Slide 12 of 14
Querying and Managing Data Using SQL Server 2005
Summary


               In this session, you learned that:
                  Service Broker provides a platform that allows the developers
                  to create asynchronous and reliable query processing.
                  In Service Broker, the developers create services that
                  converse with each other by sending and receiving messages.
                  A message is data exchanged between services.
                  Each message is of a specific message type.
                  A service is a database object that provides an endpoint for a
                  conversation.
                  A contract is an agreement between the services that
                  participate in a conversation.
                  Each service is associated with a queue that acts as a
                  container that stores messages.
                  A service program provides the required service to which a
                  message is forwarded by the queue for processing.

    Ver. 1.0                       Session 18                           Slide 13 of 14
Querying and Managing Data Using SQL Server 2005
Summary (Contd.)


               When implementing Service Broker, you need to create
               message, queue, contract, service, and conversation database
               objects.
               A message can be created by using the CREATE MESSAGE
               TYPE command.
               A queue can be created by using the CREATE QUEUE
               command.
               A contract can be created by using the CREATE CONTRACT
               command.
               A service can be created by using the CREATE SERVICE
               command.
               A conversation can be started by using the BEGIN DIALOG
               command.
               Messages can be sent by using the SEND ON
               CONVERSATION command.


    Ver. 1.0                   Session 18                          Slide 14 of 14

Weitere ähnliche Inhalte

Ähnlich wie 13 qmds2005 session18

10 qmds2005 session14
10 qmds2005 session1410 qmds2005 session14
10 qmds2005 session14Niit Care
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorialAbhi Arya
 
Session 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufSession 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufCTE Solutions Inc.
 
Administrators manual
Administrators manualAdministrators manual
Administrators manualScrumDesk
 
Administrators manual
Administrators manualAdministrators manual
Administrators manualScrumDesk
 
Weblogic 11g admin basic with screencast
Weblogic 11g admin basic with screencastWeblogic 11g admin basic with screencast
Weblogic 11g admin basic with screencastRajiv Gupta
 
A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & RESTSanthu Rao
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsSalesforce Developers
 
Ordina SOFTC Presentation - Visual Studio LightSwitch
Ordina SOFTC Presentation - Visual Studio LightSwitchOrdina SOFTC Presentation - Visual Studio LightSwitch
Ordina SOFTC Presentation - Visual Studio LightSwitchOrdina Belgium
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernatebwullems
 
Defy Occassionally Connected Challenges With Smart Client Applications
Defy Occassionally Connected Challenges With Smart Client ApplicationsDefy Occassionally Connected Challenges With Smart Client Applications
Defy Occassionally Connected Challenges With Smart Client ApplicationsClint Edmonson
 
IBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic InvestmentIBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic InvestmentStrongback Consulting
 
Making Rational HATS a Strategic Investment
Making Rational HATS a Strategic InvestmentMaking Rational HATS a Strategic Investment
Making Rational HATS a Strategic InvestmentStrongback Consulting
 
23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqraijaprr_editor
 
Wcf Transaction Handling
Wcf Transaction HandlingWcf Transaction Handling
Wcf Transaction HandlingGaurav Arora
 
Analysis of sql server services
Analysis of sql server servicesAnalysis of sql server services
Analysis of sql server servicesArchana Jha
 
Global Advertising, Inc.
Global Advertising, Inc.Global Advertising, Inc.
Global Advertising, Inc.Nicole Wells
 
KEAB - Technical Whitepaper - Kayxo Exchange Adapter for BizTalk
KEAB - Technical Whitepaper - Kayxo Exchange Adapter for BizTalk KEAB - Technical Whitepaper - Kayxo Exchange Adapter for BizTalk
KEAB - Technical Whitepaper - Kayxo Exchange Adapter for BizTalk Kayxo
 
Build Message-Based Web Services for SOA
Build Message-Based Web Services for SOABuild Message-Based Web Services for SOA
Build Message-Based Web Services for SOAJeffrey Hasan
 

Ähnlich wie 13 qmds2005 session18 (20)

10 qmds2005 session14
10 qmds2005 session1410 qmds2005 session14
10 qmds2005 session14
 
SQL Server Service Brokers
SQL Server Service BrokersSQL Server Service Brokers
SQL Server Service Brokers
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorial
 
Session 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufSession 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian Malbeuf
 
Administrators manual
Administrators manualAdministrators manual
Administrators manual
 
Administrators manual
Administrators manualAdministrators manual
Administrators manual
 
Weblogic 11g admin basic with screencast
Weblogic 11g admin basic with screencastWeblogic 11g admin basic with screencast
Weblogic 11g admin basic with screencast
 
A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & REST
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
 
Ordina SOFTC Presentation - Visual Studio LightSwitch
Ordina SOFTC Presentation - Visual Studio LightSwitchOrdina SOFTC Presentation - Visual Studio LightSwitch
Ordina SOFTC Presentation - Visual Studio LightSwitch
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernate
 
Defy Occassionally Connected Challenges With Smart Client Applications
Defy Occassionally Connected Challenges With Smart Client ApplicationsDefy Occassionally Connected Challenges With Smart Client Applications
Defy Occassionally Connected Challenges With Smart Client Applications
 
IBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic InvestmentIBM Innovate 2013: Making Rational HATS a Strategic Investment
IBM Innovate 2013: Making Rational HATS a Strategic Investment
 
Making Rational HATS a Strategic Investment
Making Rational HATS a Strategic InvestmentMaking Rational HATS a Strategic Investment
Making Rational HATS a Strategic Investment
 
23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra
 
Wcf Transaction Handling
Wcf Transaction HandlingWcf Transaction Handling
Wcf Transaction Handling
 
Analysis of sql server services
Analysis of sql server servicesAnalysis of sql server services
Analysis of sql server services
 
Global Advertising, Inc.
Global Advertising, Inc.Global Advertising, Inc.
Global Advertising, Inc.
 
KEAB - Technical Whitepaper - Kayxo Exchange Adapter for BizTalk
KEAB - Technical Whitepaper - Kayxo Exchange Adapter for BizTalk KEAB - Technical Whitepaper - Kayxo Exchange Adapter for BizTalk
KEAB - Technical Whitepaper - Kayxo Exchange Adapter for BizTalk
 
Build Message-Based Web Services for SOA
Build Message-Based Web Services for SOABuild Message-Based Web Services for SOA
Build Message-Based Web Services for SOA
 

Mehr von Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Kürzlich hochgeladen

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 

Kürzlich hochgeladen (20)

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 

13 qmds2005 session18

  • 1. Querying and Managing Data Using SQL Server 2005 Objectives In this session, you will learn to: Appreciate message-based communication Implement Service Broker Ver. 1.0 Session 18 Slide 1 of 14
  • 2. Querying and Managing Data Using SQL Server 2005 Introduction to Service Broker • Flash presentation: Implementing Service Broker Ver. 1.0 Session 18 Slide 2 of 14
  • 3. Querying and Managing Data Using SQL Server 2005 Introduction to Service Broker Conversation Process Is explained by the following diagram. Ver. 1.0 Session 18 Slide 3 of 14
  • 4. Querying and Managing Data Using SQL Server 2005 Just a minute Which of the following objects processes a message from a queue? 1. Service 2. Service program 3. Contract Answer: 1. Service program Ver. 1.0 Session 18 Slide 4 of 14
  • 5. Querying and Managing Data Using SQL Server 2005 Creating Messages Message: Is an entity that is exchanged between the Service Broker services Can contain a validation over the datatype that a message possesses Is of a specific message type • Message Type: Can be created by using the CREATE MESSAGE TYPE command Syntax: CREATE MESSAGE TYPE message_type_name [ VALIDATION = { NONE | EMPTY | WELL_FORMED_XML | VALID_XML WITH SCHEMA COLLECTION schema_collection_name } ] [ ; ] Let’s see how… Ver. 1.0 Session 18 Slide 5 of 14
  • 6. Querying and Managing Data Using SQL Server 2005 Creating Queues Queue: Is an object that stores the messages Can be viewed like a pipeline for messages Is created by using the CREATE QUEUE command Syntax: CREATE QUEUE <object> [ WITH [ STATUS = { ON | OFF } [ , ] ] [ RETENTION = { ON | OFF } [ , ] ] [ ACTIVATION ( [ STATUS = { ON | OFF } , ] PROCEDURE_NAME = <procedure> , MAX_QUEUE_READERS = max_readers , EXECUTE AS { SELF | 'user_name' | OWNER } ) ] ] Let’s see how… Ver. 1.0 Session 18 Slide 6 of 14
  • 7. Querying and Managing Data Using SQL Server 2005 Creating Contracts Contract: Is an agreement between two services that need to communicate with each other Specifies the type of message that will be used in a conversation Is created by using the CREATE CONTRACT command Syntax: CREATE CONTRACT contract_name [ AUTHORIZATION owner_name ] ( { { message_type_name | [ DEFAULT ] } SENT BY { INITIATOR | TARGET | ANY } } [ ,...n] ) [ ; ] Let’s see how… Ver. 1.0 Session 18 Slide 7 of 14
  • 8. Querying and Managing Data Using SQL Server 2005 Creating Services Service: Is used by the Service Broker to deliver messages to the correct queue within a database Is used to route messages, to enforce the contract for a conversation, and to determine the remote security for a new conversation Is created by using the CREATE SERVICE command Syntax: CREATE SERVICE service_name [ AUTHORIZATION owner_name ] ON QUEUE [ schema_name. ]queue_name [ ( contract_name | [DEFAULT] [ ,...n ] ) ] [ ; ] Let’s see how… Ver. 1.0 Session 18 Slide 8 of 14
  • 9. Querying and Managing Data Using SQL Server 2005 Beginning a Conversation Services communicate through a dialog. Conversation can begin using the BEGIN DIALOG command. Syntax: BEGIN DIALOG [ CONVERSATION ] @dialog_handle FROM SERVICE initiator_service_name TO SERVICE 'target_service_name'] [ ON CONTRACT contract_name ] Let’s see how… Ver. 1.0 Session 18 Slide 9 of 14
  • 10. Querying and Managing Data Using SQL Server 2005 Sending and Receiving Messages • Messages are sent using the SEND ON CONVERSATION command. • Syntax: SEND ON CONVERSATION conversation_handle [ MESSAGE TYPE message_type_name ] [ ( message_body_expression ) ] [ ; ] Let’s see how… Ver. 1.0 Session 18 Slide 10 of 14
  • 11. Querying and Managing Data Using SQL Server 2005 Demo: Implementing Service Broker Problem Statement: The management of AdventureWorks, Inc. wants to know the exact yearly sales at any point of the year to help them plan future strategies. The aggregated yearly sales data is maintained in the SalesDetails table of the SalesDB database. The sales transaction details are stored in the SalesOrderHeader and SalesOrderDetails tables in the AdventureWorks database. To keep the yearly sales data updated, you need to ensure that whenever any order is processed and its shipping date is updated in the AdventureWorks database, the total monetary value of that order, stored in the SubTotal column of the table, should be added to the total yearly sales in the SalesDB database. Ver. 1.0 Session 18 Slide 11 of 14
  • 12. Querying and Managing Data Using SQL Server 2005 Demo: Implementing Service Broker Solution: To solve the preceding problem, you need to perform the following tasks: 1. Create a service program. 2. Create message types, contract, queues, and service objects. 3. Create a trigger on the SalesOrderHeader table. 4. Verify the functionality. Ver. 1.0 Session 18 Slide 12 of 14
  • 13. Querying and Managing Data Using SQL Server 2005 Summary In this session, you learned that: Service Broker provides a platform that allows the developers to create asynchronous and reliable query processing. In Service Broker, the developers create services that converse with each other by sending and receiving messages. A message is data exchanged between services. Each message is of a specific message type. A service is a database object that provides an endpoint for a conversation. A contract is an agreement between the services that participate in a conversation. Each service is associated with a queue that acts as a container that stores messages. A service program provides the required service to which a message is forwarded by the queue for processing. Ver. 1.0 Session 18 Slide 13 of 14
  • 14. Querying and Managing Data Using SQL Server 2005 Summary (Contd.) When implementing Service Broker, you need to create message, queue, contract, service, and conversation database objects. A message can be created by using the CREATE MESSAGE TYPE command. A queue can be created by using the CREATE QUEUE command. A contract can be created by using the CREATE CONTRACT command. A service can be created by using the CREATE SERVICE command. A conversation can be started by using the BEGIN DIALOG command. Messages can be sent by using the SEND ON CONVERSATION command. Ver. 1.0 Session 18 Slide 14 of 14

Hinweis der Redaktion

  1. Refer SG to explain
  2. Refer SG to explain
  3. For example, the following statement creates a message type named sendMessage: CREATE MESSAGE TYPE sendMessage VALIDATION = WELL_FORMED_XML The above statements create a message type named sendMessage, which ensures that the message is a valid XML snippet.
  4. For example, the following statements create a queue named sendQueue: CREATE QUEUE sendQueue WITH STATUS = OFF, RETENTION = ON, ACTIVATION ( PROCEDURE_NAME = dbo.sendProc, MAX_QUEUE_READERS = 10, EXECUTE AS SELF ) ON [DEFAULT] ; The above stated statements create a queue named sendQueue which has sendProc as a service program attached to it.
  5. For example, the following statements create a contract named sendContract: CREATE CONTRACT sendContract ( sendMessage SENT BY INITIATOR );
  6. For example, the following statements create a service named sendService: CREATE SERVICE sendService ON QUEUE [dbo].[sendQueue] (sendContract)
  7. For example, the following statements begin a conversation between service sendMessage and receiveMessage on the contract named sendContrace: DECLARE @dialog_handle UNIQUEIDENTIFIER ; BEGIN DIALOG CONVERSATION @dialog_handle FROM SERVICE [sendService] TO SERVICE &apos;recieveService&apos; ON CONTRACT [sendContract] ;
  8. For example, the following example sends a message named sendMessage SEND ON CONVERSATION @dialog_conversation [sendMessage] [&lt;name&gt;John&lt;/name&gt;]
  9. For this activity, you need to create another database, named SalesDB. To create this database, you can use the Chapter11_datafile.sql data file given in the Datafiles_for_faculty\\Chapter 11 folder in the TIRM CD.
  10. You can also check that the transaction is committed even if the database is not available by detaching the database. Next, you can execute the INSERT statement in the Sales.SalesOrderHeader table in the AdventureWorks database. The record will be inserted in the table even if the SalesDB database is not available. Finally, you can again attach the SalesDB database. After attaching the database, you will notice that the sales amount will be added to the total yearly sales amount.
  11. You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
  12. You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.