Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Messaging / Completion.cs / 1 / Completion.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // Define the interfaces and infrastructure needed to receive completion messages using System; using System.ServiceModel.Channels; using System.Diagnostics; using System.ServiceModel; using Microsoft.Transactions.Wsat.Protocol; using DiagnosticUtility = Microsoft.Transactions.Bridge.DiagnosticUtility; namespace Microsoft.Transactions.Wsat.Messaging { interface ICompletionCoordinator { void Commit(Message message); void Rollback(Message message); void Fault(Message message, MessageFault messageFault); } interface ICompletionParticipant { void Committed(Message message); void Aborted(Message message); void Fault(Message message, MessageFault messageFault); } //===================================================================================================== // CompletionCoordinatorDispatcher Classes //===================================================================================================== class CompletionCoordinatorDispatcher : DatagramMessageDispatcher { CoordinationService service; ICompletionCoordinator dispatch; public CompletionCoordinatorDispatcher(CoordinationService service, ICompletionCoordinator dispatch) : base(service.ProtocolVersion) { this.service = service; this.dispatch = dispatch; } protected override DatagramProxy CreateFaultProxy (EndpointAddress to) { return this.service.CreateCompletionParticipantProxy(to); } public void Commit(Message message) { try { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Dispatching completion Commit message"); if (DebugTrace.Pii) DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message)); } CommitMessage.ReadFrom (message, this.service.ProtocolVersion); this.dispatch.Commit (message); } catch (CommunicationException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Warning); this.OnMessageException (message, e); } #pragma warning suppress 56500 // Only catch Exception for InvokeFinalHandler catch (Exception e) { DebugTrace.Trace ( TraceLevel.Error, "Unhandled exception {0} dispatching completion Commit message: {1}", e.GetType().Name, e ); // Contractually the dispatch object can only throw CommunicationException. // Our implementation is very careful to only throw this type of exception // (e.g. when deserializing a malformed message body or header...) // Any other exception indicates that things have gone seriously wrong, // so we cannot be trusted to process further messages. This is a QFE-worthy event. DiagnosticUtility.InvokeFinalHandler(e); } } public void Rollback(Message message) { try { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Dispatching completion Rollback message"); if (DebugTrace.Pii) DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message)); } RollbackMessage.ReadFrom (message, this.service.ProtocolVersion); this.dispatch.Rollback (message); } catch (CommunicationException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Warning); this.OnMessageException (message, e); } #pragma warning suppress 56500 // Only catch Exception for InvokeFinalHandler catch (Exception e) { DebugTrace.Trace ( TraceLevel.Error, "Unhandled exception {0} dispatching completion Rollback message: {1}", e.GetType().Name, e ); // Contractually the dispatch object can only throw CommunicationException. // Our implementation is very careful to only throw this type of exception // (e.g. when deserializing a malformed message body or header...) // Any other exception indicates that things have gone seriously wrong, // so we cannot be trusted to process further messages. This is a QFE-worthy event. DiagnosticUtility.InvokeFinalHandler(e); } } public void WsaFault(Message message) { Fault(message); } public void WscoorFault(Message message) { Fault(message); } public void WsatFault(Message message) { Fault(message); } void Fault(Message message) { try { MessageFault fault = MessageFault.CreateFault (message, CoordinationBinding.MaxFaultSize); if (DebugTrace.Verbose) { FaultCode code = Library.GetBaseFaultCode (fault); DebugTrace.Trace(TraceLevel.Verbose, "Dispatching participant completion fault {0}", code == null ? "unknown" : code.Name); if (DebugTrace.Pii) DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message)); } this.dispatch.Fault(message, fault); } catch (CommunicationException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Warning); this.OnMessageException(message, e); } #pragma warning suppress 56500 // Only catch Exception for InvokeFinalHandler catch (Exception e) { DebugTrace.Trace ( TraceLevel.Error, "Unhandled exception {0} dispatching completion fault from participant: {1}", e.GetType().Name, e ); // Contractually the dispatch object can only throw CommunicationException. // Our implementation is very careful to only throw this type of exception // (e.g. when deserializing a malformed message body or header...) // Any other exception indicates that things have gone seriously wrong, // so we cannot be trusted to process further messages. This is a QFE-worthy event. DiagnosticUtility.InvokeFinalHandler(e); } } public static IWSCompletionCoordinator Instance(CoordinationService service, ICompletionCoordinator dispatch) { ProtocolVersionHelper.AssertProtocolVersion(service.ProtocolVersion, typeof(CompletionCoordinatorDispatcher), "Instance"); //assert valid protocol version switch (service.ProtocolVersion) { case ProtocolVersion.Version10: return new CompletionCoordinatorDispatcher10(service, dispatch); case ProtocolVersion.Version11: return new CompletionCoordinatorDispatcher11(service, dispatch); default: return null; // inaccessible path because we have asserted the protocol version } } } [ServiceBehavior ( InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] class CompletionCoordinatorDispatcher10 : IWSCompletionCoordinator10 { CompletionCoordinatorDispatcher completionCoordinatorDispatcher; public CompletionCoordinatorDispatcher10(CoordinationService service, ICompletionCoordinator dispatch) { ProtocolVersionHelper.AssertProtocolVersion10(service.ProtocolVersion, typeof(CompletionCoordinatorDispatcher10), "constr"); this.completionCoordinatorDispatcher = new CompletionCoordinatorDispatcher(service, dispatch); } public Type ContractType { get { return typeof(IWSCompletionCoordinator10); } } public void Commit (Message message) { this.completionCoordinatorDispatcher.Commit(message); } public void Rollback (Message message) { this.completionCoordinatorDispatcher.Rollback(message); } public void WsaFault(Message message) { this.completionCoordinatorDispatcher.WsaFault(message); } public void WscoorFault(Message message) { this.completionCoordinatorDispatcher.WscoorFault(message); } public void WsatFault(Message message) { this.completionCoordinatorDispatcher.WsatFault(message); } } [ServiceBehavior ( InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] class CompletionCoordinatorDispatcher11 : IWSCompletionCoordinator11 { CompletionCoordinatorDispatcher completionCoordinatorDispatcher; public CompletionCoordinatorDispatcher11(CoordinationService service, ICompletionCoordinator dispatch) { ProtocolVersionHelper.AssertProtocolVersion11(service.ProtocolVersion, typeof(CompletionCoordinatorDispatcher11), "constr"); this.completionCoordinatorDispatcher = new CompletionCoordinatorDispatcher(service, dispatch); } public Type ContractType { get { return typeof(IWSCompletionCoordinator11); } } public void Commit (Message message) { this.completionCoordinatorDispatcher.Commit(message); } public void Rollback (Message message) { this.completionCoordinatorDispatcher.Rollback(message); } public void WsaFault(Message message) { this.completionCoordinatorDispatcher.WsaFault(message); } public void WscoorFault(Message message) { this.completionCoordinatorDispatcher.WscoorFault(message); } public void WsatFault(Message message) { this.completionCoordinatorDispatcher.WsatFault(message); } } //====================================================================================================== class CompletionParticipantDispatcher : DatagramMessageDispatcher { CoordinationService service; ICompletionParticipant dispatch; public CompletionParticipantDispatcher (CoordinationService service, ICompletionParticipant dispatch) : base(service.ProtocolVersion) { this.service = service; this.dispatch = dispatch; } protected override DatagramProxy CreateFaultProxy (EndpointAddress to) { return this.service.CreateCompletionCoordinatorProxy (to, null); } public void Committed (Message message) { try { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Dispatching completion Committed message"); if (DebugTrace.Pii) DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message)); } CommittedMessage.ReadFrom(message, this.service.ProtocolVersion); this.dispatch.Committed(message); } catch (CommunicationException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Warning); this.OnMessageException(message, e); } #pragma warning suppress 56500 // Only catch Exception for InvokeFinalHandler catch (Exception e) { DebugTrace.Trace ( TraceLevel.Error, "Unhandled exception {0} dispatching completion Committed message: {1}", e.GetType().Name, e ); // Contractually the dispatch object can only throw CommunicationException. // Our implementation is very careful to only throw this type of exception // (e.g. when deserializing a malformed message body or header...) // Any other exception indicates that things have gone seriously wrong, // so we cannot be trusted to process further messages. This is a QFE-worthy event. DiagnosticUtility.InvokeFinalHandler(e); } } public void Aborted(Message message) { try { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Dispatching completion Aborted message"); if (DebugTrace.Pii) DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message)); } AbortedMessage.ReadFrom (message, this.service.ProtocolVersion); this.dispatch.Aborted(message); } catch (CommunicationException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Warning); this.OnMessageException (message, e); } #pragma warning suppress 56500 // Only catch Exception for InvokeFinalHandler catch (Exception e) { DebugTrace.Trace ( TraceLevel.Error, "Unhandled exception {0} dispatching completion Aborted message: {1}", e.GetType().Name, e ); // Contractually the dispatch object can only throw CommunicationException. // Our implementation is very careful to only throw this type of exception // (e.g. when deserializing a malformed message body or header...) // Any other exception indicates that things have gone seriously wrong, // so we cannot be trusted to process further messages. This is a QFE-worthy event. DiagnosticUtility.InvokeFinalHandler (e); } } public void WsaFault(Message message) { Fault(message); } public void WscoorFault(Message message) { Fault(message); } public void WsatFault(Message message) { Fault(message); } void Fault(Message message) { try { MessageFault fault = MessageFault.CreateFault(message, CoordinationBinding.MaxFaultSize); if (DebugTrace.Verbose) { FaultCode code = Library.GetBaseFaultCode(fault); DebugTrace.Trace(TraceLevel.Verbose, "Dispatching coordinator completion fault {0}", code == null ? "unknown" : code.Name); if (DebugTrace.Pii) DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message)); } this.dispatch.Fault(message, fault); } catch (CommunicationException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Warning); this.OnMessageException(message, e); } #pragma warning suppress 56500 // Only catch Exception for InvokeFinalHandler catch (Exception e) { DebugTrace.Trace ( TraceLevel.Error, "Unhandled exception {0} dispatching completion fault from coordinator: {1}", e.GetType().Name, e ); // Contractually the dispatch object can only throw CommunicationException. // Our implementation is very careful to only throw this type of exception // (e.g. when deserializing a malformed message body or header...) // Any other exception indicates that things have gone seriously wrong, // so we cannot be trusted to process further messages. This is a QFE-worthy event. DiagnosticUtility.InvokeFinalHandler(e); } } public static IWSCompletionParticipant Instance(CoordinationService service, ICompletionParticipant dispatch) { ProtocolVersionHelper.AssertProtocolVersion(service.ProtocolVersion, typeof(CompletionParticipantDispatcher), "Instance"); //assert valid protocol version switch (service.ProtocolVersion) { case ProtocolVersion.Version10: return new CompletionParticipantDispatcher10(service, dispatch); case ProtocolVersion.Version11: return new CompletionParticipantDispatcher11(service, dispatch); default: return null; //inaccessible path because we have asserted the protocol version } } } [ServiceBehavior ( InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] class CompletionParticipantDispatcher10 : IWSCompletionParticipant10 { CompletionParticipantDispatcher completionParticipantDispatcher; public CompletionParticipantDispatcher10(CoordinationService service, ICompletionParticipant dispatch) { ProtocolVersionHelper.AssertProtocolVersion10(service.ProtocolVersion, typeof(CompletionParticipantDispatcher10), "constr"); this.completionParticipantDispatcher = new CompletionParticipantDispatcher(service, dispatch); } public Type ContractType { get { return typeof(IWSCompletionParticipant10); } } public void Committed (Message message) { this.completionParticipantDispatcher.Committed(message); } public void Aborted(Message message) { this.completionParticipantDispatcher.Aborted(message); } public void WsaFault(Message message) { this.completionParticipantDispatcher.WsaFault(message); } public void WscoorFault(Message message) { this.completionParticipantDispatcher.WscoorFault(message); } public void WsatFault(Message message) { this.completionParticipantDispatcher.WsatFault(message); } } [ServiceBehavior ( InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] class CompletionParticipantDispatcher11 : IWSCompletionParticipant11 { CompletionParticipantDispatcher completionParticipantDispatcher; public CompletionParticipantDispatcher11(CoordinationService service, ICompletionParticipant dispatch) { ProtocolVersionHelper.AssertProtocolVersion11(service.ProtocolVersion, typeof(CompletionParticipantDispatcher11), "constr"); this.completionParticipantDispatcher = new CompletionParticipantDispatcher(service, dispatch); } public Type ContractType { get { return typeof(IWSCompletionParticipant11); } } public void Committed (Message message) { this.completionParticipantDispatcher.Committed(message); } public void Aborted(Message message) { this.completionParticipantDispatcher.Aborted(message); } public void WsaFault(Message message) { this.completionParticipantDispatcher.WsaFault(message); } public void WscoorFault(Message message) { this.completionParticipantDispatcher.WscoorFault(message); } public void WsatFault(Message message) { this.completionParticipantDispatcher.WsatFault(message); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ContextInformation.cs
- ComNativeDescriptor.cs
- UnsafeNativeMethodsTablet.cs
- Assert.cs
- ToolboxItem.cs
- RawContentTypeMapper.cs
- DetailsViewInsertEventArgs.cs
- Int32RectValueSerializer.cs
- AutoGeneratedField.cs
- SynchronizationContext.cs
- GridLengthConverter.cs
- TextTreeUndo.cs
- Figure.cs
- OptimalTextSource.cs
- DataGridViewDataErrorEventArgs.cs
- Soap12ProtocolImporter.cs
- SmtpReplyReader.cs
- LayoutEditorPart.cs
- RequestQueryParser.cs
- pingexception.cs
- CodeObjectCreateExpression.cs
- StreamingContext.cs
- DBPropSet.cs
- translator.cs
- ResourcesBuildProvider.cs
- PageSetupDialog.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- VirtualPathUtility.cs
- CodeNamespaceImportCollection.cs
- ContentTextAutomationPeer.cs
- RepeatInfo.cs
- ServiceOperationViewControl.cs
- OutKeywords.cs
- TranslateTransform3D.cs
- ServiceElement.cs
- ReturnEventArgs.cs
- ListBox.cs
- Span.cs
- ClientBuildManagerCallback.cs
- Camera.cs
- followingquery.cs
- SyntaxCheck.cs
- JsonObjectDataContract.cs
- TrackingMemoryStreamFactory.cs
- GiveFeedbackEventArgs.cs
- OleDbException.cs
- EndEvent.cs
- AppDomainShutdownMonitor.cs
- StateMachineWorkflowInstance.cs
- HtmlInputPassword.cs
- SqlNotificationEventArgs.cs
- SHA256.cs
- WebPartAddingEventArgs.cs
- XdrBuilder.cs
- Vector3DCollection.cs
- QilTernary.cs
- sitestring.cs
- QueryNode.cs
- MenuCommand.cs
- EdmSchemaAttribute.cs
- EntryIndex.cs
- EmbeddedMailObjectsCollection.cs
- OrderedDictionary.cs
- CacheRequest.cs
- PhysicalAddress.cs
- Renderer.cs
- ProjectionPruner.cs
- ArrayList.cs
- Classification.cs
- Utils.cs
- PhoneCall.cs
- HasCopySemanticsAttribute.cs
- Latin1Encoding.cs
- BaseValidator.cs
- LocatorPartList.cs
- BlobPersonalizationState.cs
- IPHostEntry.cs
- UnsafeNativeMethods.cs
- DataViewManager.cs
- TextFormatterImp.cs
- ModulesEntry.cs
- MobileListItemCollection.cs
- SqlConnectionPoolProviderInfo.cs
- ToolStripSettings.cs
- DbProviderFactoriesConfigurationHandler.cs
- NameSpaceExtractor.cs
- TextBoxLine.cs
- ImportStoreException.cs
- SecurityResources.cs
- CharConverter.cs
- XmlSchemaAttributeGroupRef.cs
- FontSource.cs
- RelationshipFixer.cs
- DeferredElementTreeState.cs
- WindowProviderWrapper.cs
- CustomErrorCollection.cs
- TextTreeDeleteContentUndoUnit.cs
- CollectionBase.cs
- XmlWriterSettings.cs
- VolatileEnlistmentMultiplexing.cs