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
- ProtocolsConfigurationEntry.cs
- SortAction.cs
- ObjectItemAssemblyLoader.cs
- NameHandler.cs
- ConfigurationStrings.cs
- MsmqInputMessage.cs
- Base64Stream.cs
- TdsParser.cs
- OutputCacheProfileCollection.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- Crc32.cs
- TreeNodeBinding.cs
- GridViewColumnCollection.cs
- Label.cs
- SubpageParagraph.cs
- BinaryUtilClasses.cs
- ExternalException.cs
- DataGridViewCellValidatingEventArgs.cs
- MSAAWinEventWrap.cs
- Paragraph.cs
- WriteLine.cs
- FirstQueryOperator.cs
- AsymmetricSignatureDeformatter.cs
- WpfWebRequestHelper.cs
- ConstructorNeedsTagAttribute.cs
- DbConnectionStringCommon.cs
- WebAdminConfigurationHelper.cs
- SqlDeflator.cs
- XmlDataSourceView.cs
- TagPrefixInfo.cs
- MsmqChannelFactoryBase.cs
- DataGridViewRowPrePaintEventArgs.cs
- NameValuePermission.cs
- EdmItemError.cs
- BinaryFormatterSinks.cs
- WorkflowInstanceContextProvider.cs
- ThicknessAnimationBase.cs
- State.cs
- SendKeys.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- SocketPermission.cs
- TextTrailingCharacterEllipsis.cs
- OdbcCommandBuilder.cs
- AttachmentService.cs
- PointUtil.cs
- DelegatedStream.cs
- VisualBasicValue.cs
- FormsIdentity.cs
- PLINQETWProvider.cs
- ISO2022Encoding.cs
- RequiredFieldValidator.cs
- DoubleSumAggregationOperator.cs
- Stack.cs
- NetSectionGroup.cs
- StrongBox.cs
- PropertyNames.cs
- MultiBinding.cs
- WebPartDeleteVerb.cs
- FilteredAttributeCollection.cs
- SqlBuffer.cs
- InitializationEventAttribute.cs
- Membership.cs
- WebPartConnection.cs
- WebPartConnectionsCloseVerb.cs
- TimeoutException.cs
- XsdDuration.cs
- NextPreviousPagerField.cs
- LocatorManager.cs
- PTProvider.cs
- FontDifferentiator.cs
- OdbcException.cs
- LinqToSqlWrapper.cs
- PasswordRecovery.cs
- RsaSecurityKey.cs
- Switch.cs
- ComponentResourceKey.cs
- WindowsGraphicsWrapper.cs
- TemplatedControlDesigner.cs
- CompositeControl.cs
- ObjectDataSource.cs
- SEHException.cs
- ErrorTableItemStyle.cs
- HostUtils.cs
- GenerateTemporaryTargetAssembly.cs
- InfiniteIntConverter.cs
- AppDomainAttributes.cs
- tooltip.cs
- DrawingBrush.cs
- DetailsViewModeEventArgs.cs
- DependencyPropertyAttribute.cs
- TextCompositionEventArgs.cs
- ObjectDataSourceSelectingEventArgs.cs
- ContentPosition.cs
- MsmqSecureHashAlgorithm.cs
- Path.cs
- OutputCacheProviderCollection.cs
- ConnectionManagementElementCollection.cs
- Argument.cs
- PropertyChangingEventArgs.cs
- UserValidatedEventArgs.cs