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
- CodeAttributeDeclaration.cs
- ServiceDeploymentInfo.cs
- EncoderParameter.cs
- ByteStream.cs
- HuffModule.cs
- SortedSetDebugView.cs
- AndCondition.cs
- AnnotationAdorner.cs
- CompiledRegexRunner.cs
- NGCPageContentSerializerAsync.cs
- TraceXPathNavigator.cs
- RtfNavigator.cs
- ComponentResourceKeyConverter.cs
- XmlUrlResolver.cs
- IndexedGlyphRun.cs
- InProcStateClientManager.cs
- EarlyBoundInfo.cs
- BaseDataBoundControl.cs
- InertiaTranslationBehavior.cs
- AliasedSlot.cs
- ExpressionParser.cs
- SolidBrush.cs
- AsymmetricSignatureFormatter.cs
- CacheChildrenQuery.cs
- HijriCalendar.cs
- SizeAnimationUsingKeyFrames.cs
- ToolTip.cs
- OuterGlowBitmapEffect.cs
- SmiEventSink_DeferedProcessing.cs
- MissingManifestResourceException.cs
- TextPatternIdentifiers.cs
- UriTemplateLiteralPathSegment.cs
- TemplateControlCodeDomTreeGenerator.cs
- BaseServiceProvider.cs
- EventLogPermission.cs
- IntSecurity.cs
- TextServicesLoader.cs
- HttpBrowserCapabilitiesWrapper.cs
- SQLInt16Storage.cs
- InheritanceService.cs
- CompilerHelpers.cs
- NativeMethods.cs
- BrushValueSerializer.cs
- ExtendedProtectionPolicy.cs
- TextViewDesigner.cs
- ListCommandEventArgs.cs
- BaseValidatorDesigner.cs
- LinkDescriptor.cs
- SQLBytesStorage.cs
- CompositeScriptReferenceEventArgs.cs
- Context.cs
- AsnEncodedData.cs
- StyleCollection.cs
- SplitterEvent.cs
- HtmlControlPersistable.cs
- CustomErrorsSectionWrapper.cs
- CopyNodeSetAction.cs
- UserPersonalizationStateInfo.cs
- StateDesigner.Layouts.cs
- ControlParameter.cs
- TextComposition.cs
- SecurityValidationBehavior.cs
- ControlDesignerState.cs
- ExeContext.cs
- SoapMessage.cs
- ParameterElementCollection.cs
- HTMLTagNameToTypeMapper.cs
- FunctionNode.cs
- HttpPostedFileBase.cs
- SchemaContext.cs
- HtmlMeta.cs
- AccessKeyManager.cs
- Formatter.cs
- IOException.cs
- StateDesigner.TransitionInfo.cs
- SmtpMail.cs
- ErrorEventArgs.cs
- ObservableCollectionDefaultValueFactory.cs
- x509utils.cs
- ThreadStaticAttribute.cs
- OleAutBinder.cs
- SpeechSeg.cs
- XmlElement.cs
- PermissionListSet.cs
- RepeaterItemEventArgs.cs
- ReflectionPermission.cs
- Vector.cs
- PropertyInfoSet.cs
- TextAnchor.cs
- _AutoWebProxyScriptWrapper.cs
- ImageCollectionEditor.cs
- BitmapEffectGeneralTransform.cs
- TemplatedWizardStep.cs
- DataSourceXmlTextReader.cs
- SplitterCancelEvent.cs
- WebInvokeAttribute.cs
- ObjectDataProvider.cs
- PositiveTimeSpanValidatorAttribute.cs
- ArrayEditor.cs
- _LocalDataStore.cs