Windows Communication Foundation (“Indigo”): Writing Reliable and Transacted Distributed...
-
Upload
moses-hodge -
Category
Documents
-
view
218 -
download
0
Transcript of Windows Communication Foundation (“Indigo”): Writing Reliable and Transacted Distributed...
Windows Communication Foundation Windows Communication Foundation (“Indigo”): (“Indigo”): Writing Reliable and Transacted Distributed Writing Reliable and Transacted Distributed ApplicationsApplications
Shy “BAD-P” CohenShy “BAD-P” CohenCOM307COM307Program ManagerProgram ManagerConnected Systems DivisionConnected Systems DivisionMicrosoft CorporationMicrosoft Corporation
2
Moving To Service Moving To Service OrientationOrientation
Threads versus MessagesThreads versus MessagesBAD P! BAD, BAD P!BAD P! BAD, BAD P!
Why don’t you come back? Please Why don’t you come back? Please hurry… ♫hurry… ♫
Keeping it ConsistentKeeping it ConsistentAll together now!All together now!
3
Challenges Of Challenges Of Implementing Reliable Implementing Reliable Distributed SystemsDistributed SystemsCommunication Communication
IssuesIssuesNetwork unavailableNetwork unavailableConnection dropsConnection dropsNetwork loses Network loses messagesmessagesMessages may arrive Messages may arrive out of orderout of order
Messages may take Messages may take different pathsdifferent pathsRetried messages may Retried messages may arrive after the ones arrive after the ones that followed themthat followed them
Processing IssuesProcessing IssuesMessages lost when Messages lost when processing failsprocessing failsInterrelated Interrelated Messages processed Messages processed individuallyindividuallyFailure may leave Failure may leave the distributed the distributed system in an system in an inconsistent stateinconsistent stateMessages can’t be Messages can’t be retried without side retried without side effectseffects
Retried messages Retried messages arriving twice, arriving twice, reordering, etc.reordering, etc.
4
Making It ReliableMaking It Reliable
Reliable Reliable SessionSession
ssTransactionTransaction
ss
QueuesQueues
5
SessionsSessions
ChannelChannel
Service Instance
ChannelChannel
Proxy
SessionSessionSessionSession
8
Session State And LifetimeSession State And Lifetime
9
Reliable Sessions Reliable Sessions AssurancesAssurances
Messages are delivered exactly once, in the Messages are delivered exactly once, in the same order as they were sentsame order as they were sent
Alternatively, you can choose to have them Alternatively, you can choose to have them delivered in order in which they were receiveddelivered in order in which they were received
Resilient toResilient toTransport disconnectionsTransport disconnections
SOAP or transport intermediary failuresSOAP or transport intermediary failures
FeaturesFeaturesConnection verification and maintenanceConnection verification and maintenance
Congestion and flow controlCongestion and flow control
10
Reliable SessionsReliable SessionsEnablingEnabling
Provided on Standard BindingsProvided on Standard BindingsnetTcpBinding netTcpBinding (off by default)
wsHttpBinding wsHttpBinding (off by default)
wsDualHttpBinding wsDualHttpBinding (always on)
Can be added to any custom bindingCan be added to any custom binding
<bindings><customBinding>
<binding configurationName=”ReliabilityHTTP”><reliableSession/><httpTransport/>
</binding></customBinding>
</bindings>
11
Ordered And Unordered Ordered And Unordered Reliable SessionsReliable Sessions
13
Keeping It ConsistentKeeping It Consistent
Atomic Transactions versus Atomic Transactions versus CompensationCompensation
Trading off coupling and complexityTrading off coupling and complexityAtomic Transactions: simpler, tighter Atomic Transactions: simpler, tighter couplingcoupling
Compensation: more complex, looser Compensation: more complex, looser couplingcoupling
Both have their placeBoth have their placeChoose the right model for the situationChoose the right model for the situation
18
Transacted OperationsTransacted Operations
19
TransactionsTransactionsSummarySummary
Service Developer (Code)Service Developer (Code)Declares willingness to participate in an incoming Declares willingness to participate in an incoming (client initiated) transaction on contract (client initiated) transaction on contract operationsoperations
No transaction sharing on one-way operations! *No transaction sharing on one-way operations! *
Specified implementation behavioral aspects at Specified implementation behavioral aspects at the service and method levelthe service and method level
Client Developer (Code)Client Developer (Code)Creates transactionsCreates transactionsIncludes services & local TX-ed resources in their Includes services & local TX-ed resources in their scopescope
Service Administrator (Config)Service Administrator (Config)On/Off switch controls TX flow support for an On/Off switch controls TX flow support for an endpointendpointIt’s about TrustIt’s about Trust
20
QueuesQueues
Increase availabilityIncrease availabilityMask network or service unavailabilityMask network or service unavailability
Support scale outSupport scale outMultiple readers from a single queueMultiple readers from a single queue
Provide load levelingProvide load levelingHandle average, not peak loadHandle average, not peak load
Are a building block for compensating Are a building block for compensating business transactionsbusiness transactions
Reliable, durable messaging to capture Reliable, durable messaging to capture distributed distributed state changesstate changes
Need to compensate for errorsNeed to compensate for errors
21
QueuesQueues
Make one-way operations possible even when Make one-way operations possible even when the service isn’t availablethe service isn’t availableSupported via MSMQSupported via MSMQ
Programmer uses regular WCF channelsProgrammer uses regular WCF channelsIT Pro manages the familiar MSMQ serviceIT Pro manages the familiar MSMQ service
MSMQMSMQMSMQMSMQ
ClienClientt
ServicServicee
24
Basic Queued MessagingBasic Queued Messaging
25
QueuesQueuesComposing with TXsComposing with TXs
Operation requires 2 transactionsOperation requires 2 transactionsTX between client and queue to sendTX between client and queue to send
Another TX between service and queue Another TX between service and queue to receiveto receive
If a transaction abortsIf a transaction abortsMessage sent under the TX are Message sent under the TX are discardeddiscarded
Messages received under the TX are Messages received under the TX are retriedretried
26
QueuesQueuesMEPsMEPs
DatagramsDatagramsStandalone messagesStandalone messages
Can be sent and received with or without Can be sent and received with or without using a transactionusing a transaction
““Exactly Once” or “Best Effort” deliveryExactly Once” or “Best Effort” delivery
““Sessiongram”Sessiongram”A grouping of related messagesA grouping of related messages
Always processed together under a Always processed together under a single TXsingle TX
““Exactly Once, In Order” deliveryExactly Once, In Order” delivery
29
Queues, Transactions, Queues, Transactions, And SessionsAnd Sessions
30
QueuesQueuesThe dead letter queueThe dead letter queue
Stores messages that could not be Stores messages that could not be delivereddelivered
Can be processed like any other queueCan be processed like any other queue
New in Windows VistaNew in Windows Vista: User specified DLQ: User specified DLQIf not specified, the default is the system-wide If not specified, the default is the system-wide DLQDLQ
With a shared DLQ, processing service needs to With a shared DLQ, processing service needs to implement all the contracts for all the messages implement all the contracts for all the messages
going into itgoing into it
Alternatively, use System.Messaging to process Alternatively, use System.Messaging to process messages from the Dead Letter Queuemessages from the Dead Letter Queue
31
QueuesQueuesPoison messagesPoison messages
Messages for whom processing fails, Messages for whom processing fails, repeatedly, are considered “poison”repeatedly, are considered “poison”
Failure = the processing transaction Failure = the processing transaction abortedaborted
Message properties indicate how Message properties indicate how many times a message was deliveredmany times a message was delivered
MsmqMessageProperty msmqMessageProperty;msmqMessageProperty = OperationContext.Current.IncomingMessageProperties[MsmqMessageProperty.Name]
as MsmqMessageProperty;if (prop.TotalAbortCount > myRetryThreshold) { /* Do something */ }
32
QueuesQueuesPoison messagesPoison messages
New in Windows VistaNew in Windows Vista: Automatic : Automatic protection against repeated failuresprotection against repeated failures
By limiting NUMBER By limiting NUMBER of retriesof retries
By controlling HOWBy controlling HOWretries are doneretries are done
<netProfileMsmqBinding> <binding configurationName=“QB" maxImmediateRetries="2" retryCycleDelay="0:0:10" maxRetryCycles="3" rejectAfterLastRetry="false" /></netProfileMsmqBinding>
10 seconds between attempts
3 retry cycles
2 retrie
s
To Poison Message Queue
1st attempt
33
Q’sQ’sFailure compensationFailure compensation
Set up compensation services on the Set up compensation services on the sending and receiving sidessending and receiving sides
<binding configurationName="MyQueueBinding“ ... timeToLive="0:2:0" deadLetterQueue= "net.msmq://MyClient/private/myCustomDLQ"/>
<endpoint address ="net.msmq://MyServer/private/MyQueue;poison/” bindingSectionName="netProfileMsmqBinding" bindingConfiguration ="MyQueueBinding" contractType="Queue.IPurchaseOrder, Queues" />
34
When Faced With When Faced With ChallengesChallenges
WCF provides sophisticated session WCF provides sophisticated session mgmtmgmt
Session lifetime and associated stateSession lifetime and associated state
WCF assuresWCF assures… … that messages arrive exactly oncethat messages arrive exactly once
… … in the order in which they were sentin the order in which they were sent
WCF provides transacted state WCF provides transacted state managementmanagement
Computation and communicationComputation and communication
WCF provides high availabilityWCF provides high availabilityDurability, atomicity, and error handlingDurability, atomicity, and error handling
35
Community ResourcesCommunity Resources
At the PDCAt the PDCMore on Windows Communication FoundationMore on Windows Communication Foundation
Attend the other WCF presentationsAttend the other WCF presentations
Talk to me and the other WCF folks at the Lounge, Ask The Talk to me and the other WCF folks at the Lounge, Ask The Experts, or at any other timeExperts, or at any other time
More on System.TransactionsMore on System.TransactionsGo talk to Max (COM lounge) or Jim (FUN lounge)Go talk to Max (COM lounge) or Jim (FUN lounge)
Attend FUN320 tomorrowAttend FUN320 tomorrow
Do the HOLs: WCF HOLs, FUN HOL13 (TXF & TXR)Do the HOLs: WCF HOLs, FUN HOL13 (TXF & TXR)
After the PDCAfter the PDCMSDN dev center: MSDN dev center: http://msdn.microsoft.com/webservices/http://msdn.microsoft.com/webservices/
MSDN ForumsMSDN Forums
Channel 9 tag: http://channel9.msdn.com/tags/IndigoChannel 9 tag: http://channel9.msdn.com/tags/Indigo
Contact me: [email protected] me: [email protected]
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.