Upload
kory-nash
View
220
Download
0
Tags:
Embed Size (px)
Citation preview
1
Building Distributed Asynchronous Building Distributed Asynchronous Applications With SQL Service Applications With SQL Service BrokerBroker
Gerald Hinson, Roger WolterGerald Hinson, Roger WolterDAT303DAT303Dev LeadDev LeadMicrosoft CorporationMicrosoft Corporation
2
AgendaAgenda
What is Service Broker?What is Service Broker?
Service Broker BasicsService Broker Basics
CLR ServicesCLR Services
Conversation Group LockingConversation Group Locking
WCF ChannelWCF Channel
Remote Service BrokerRemote Service Broker
3
SQL Service BrokerSQL Service Broker
Platform for building asynchronous,Platform for building asynchronous,loosely coupled database applicationsloosely coupled database applications
Queues are database objectsQueues are database objectsQueue locking reduces conflicts and Queue locking reduces conflicts and deadlocksdeadlocks
Dialogs give unprecedented messageDialogs give unprecedented messageordering assuranceordering assurance
Ordered across transactions, input Ordered across transactions, input applications and output applicationsapplications and output applications
New DDL and DML for messagingNew DDL and DML for messagingUse the same APIs and tools as SQLUse the same APIs and tools as SQL
Reliable messaging for scale outReliable messaging for scale out
4Database BDatabase BDatabase ADatabase A
DialogsDialogsDialogs provide two-way messaging between two servicesDialogs provide two-way messaging between two services
Dialogs offerDialogs offerGuaranteed deliveryGuaranteed delivery
Exactly-once deliveryExactly-once delivery
In-order deliveryIn-order delivery
Secure communicationsSecure communications
DialogsDialogsMay be long-lived (years) or short-lived (seconds)May be long-lived (years) or short-lived (seconds)
Are lightweightAre lightweight
Are persistent sessionsAre persistent sessions
Customer Customer ServiceService
Travel Travel ServiceService
DialogDialog
5
ServicesServices
A A ServiceService is a named endpoint that may be is a named endpoint that may be targeted with messagestargeted with messages
Its interface is defined by the messages it Its interface is defined by the messages it consumes and emitsconsumes and emits
Services are scoped by (live in) databases Services are scoped by (live in) databases
It is responsibility of a service’s Service Broker It is responsibility of a service’s Service Broker toto
1) Deliver messages sent from that service to other 1) Deliver messages sent from that service to other servicesservices
2) Store messages that are sent to that service until 2) Store messages that are sent to that service until the service can process themthe service can process them
Every service is mapped to a Every service is mapped to a QueueQueue. Messages sent to a . Messages sent to a service are stored in its associated queueservice are stored in its associated queue
Queues are a new table-like object introduced in SS 2005Queues are a new table-like object introduced in SS 2005
Messages are dequeued using a new verb: RECEIVEMessages are dequeued using a new verb: RECEIVE
Messages may be “peeked” using SELECTMessages may be “peeked” using SELECT
6
Stored ProcedureStored Procedure
Stored ProcedureStored Procedure
Internal ActivationInternal Activation
QUEUEQUEUE
7
Service Broker BasicsService Broker Basics
Gerald HinsonGerald HinsonDev LeadDev LeadSQL ServerSQL Server
8
ServiceService
ServiceService
External ActivationExternal Activation
QueueQueue
ExternalExternal
ActivatorActivator
EventEventQueueQueue
9
CLR ServicesCLR Services
Gerald HinsonGerald HinsonDev LeadDev LeadSQL ServerSQL Server
10
Queue ReaderQueue Reader
Queue ReaderQueue Reader
Conversation Group Conversation Group LockingLocking
QUEUEQUEUEDialogDialog
11
DialogDialog22DialogDialog22DialogDialog22
DialogDialog11DialogDialog11
XX
11
Conversation Group LockingConversation Group Locking
Gerald HinsonGerald HinsonDev LeadDev LeadSQL ServerSQL Server
12
WCF (“Indigo”) Channel For WCF (“Indigo”) Channel For SSBSSB
Typed ProxyTyped Proxy
SSB ChannelSSB Channel
ClientClient
ADO.NETADO.NET
SQLSQLServerServer
DispatcherDispatcher
SSB ChannelSSB Channel
ADO.NETADO.NET
SQLSQLServerServer
TDTDSS
TDTDSS
Service Service Broker Broker RoutingRouting
ServiceService
13
WCF ChannelWCF Channel
Gerald HinsonGerald HinsonDev LeadDev LeadSQL ServerSQL Server
14
CertificateCertificate
Public KeyPublic Key
CertificateCertificate
Public KeyPublic Key
InitiatorInitiator TargetTargetFROMFROM
ServiceService
MessageMessageHeaderHeader
CertificateCertificate
Private KeyPrivate Key
DB DB UserUser
DB DB UserUser
RemotRemoteServiceServic
eeBindingBinding
DB DB UserUser
AuthorizationAuthorization
CertificateCertificate
Private KeyPrivate Key
DB DB UserUser
TO TO
ServicServicee
Dialog SecurityDialog Security
15
RoutingRoutingSENDSEND
ClassifierClassifiersys.routessys.routes
16
Remote Service BrokerRemote Service Broker
Gerald HinsonGerald HinsonDev LeadDev LeadSQL ServerSQL Server
17
Service Broker ScenariosService Broker Scenarios
Asynchronous DB “Stuff”Asynchronous DB “Stuff”Asynchronous Triggers and EventsAsynchronous Triggers and Events
Parallel Stored ProceduresParallel Stored Procedures
Batches and scheduled tasksBatches and scheduled tasks
Data Warehouse populationData Warehouse population
Delayed actions in different transactionsDelayed actions in different transactions
Reliable MessagingReliable MessagingSmart ClientsSmart Clients
Point of SalePoint of Sale
Shop FloorShop Floor
Scaling out asynchronous stuffScaling out asynchronous stuff
Reliable Service Oriented ArchitectureReliable Service Oriented Architecture
18
ResourcesResources
http://blogs.msdn.com/rushidesai/http://blogs.msdn.com/rushidesai/
http://forums.microsoft.com/msdn/Shhttp://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=91owForum.aspx?ForumID=91
http://www.sqlservicebroker.com/foruhttp://www.sqlservicebroker.com/forums/ms/
http://msdn.microsoft.com/sql/2005/http://msdn.microsoft.com/sql/2005/
[email protected]@microsoft.com
19
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.