Example #1
0
        private static bool GetRemoteEnlistmentId(EndpointAddress address, out Guid remoteEnlistmentId)
        {
            AddressHeaderCollection headers = address.Headers;

            if (headers.Count == 1)
            {
                AddressHeader header = headers.FindHeader("Enlistment", "http://schemas.microsoft.com/ws/2006/02/transactions");
                if (header != null)
                {
                    XmlDictionaryReader addressHeaderReader = header.GetAddressHeaderReader();
                    XmlDictionaryReader reader2             = addressHeaderReader;
                    try
                    {
                        ControlProtocol protocol;
                        EnlistmentHeader.ReadFrom(addressHeaderReader, out remoteEnlistmentId, out protocol);
                        return(protocol == ControlProtocol.Durable2PC);
                    }
                    catch (InvalidEnlistmentHeaderException exception)
                    {
                        Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                    }
                    finally
                    {
                        if (reader2 != null)
                        {
                            reader2.Dispose();
                        }
                    }
                }
            }
            remoteEnlistmentId = Guid.Empty;
            return(false);
        }
 private EndpointAddress CreateForgottenSource()
 {
     if (this.forgottenSource == null)
     {
         EnlistmentHeader refParam = new EnlistmentHeader(Guid.Empty, ControlProtocol.None);
         this.forgottenSource = this.state.TwoPhaseCommitCoordinatorListener.CreateEndpointReference(refParam);
     }
     return(this.forgottenSource);
 }
        public void CreateParticipantService()
        {
            EnlistmentHeader refParam = new EnlistmentHeader(base.enlistmentId);

            this.participantService = base.state.TwoPhaseCommitParticipantListener.CreateEndpointReference(refParam);
            if (this.coordinatorProxy != null)
            {
                this.coordinatorProxy.From = this.participantService;
            }
        }
        public void CreateCoordinatorService()
        {
            if ((this.protocol != Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Durable2PC) && (this.protocol != Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Volatile2PC))
            {
                Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Need protocol for coordinator service");
            }
            EnlistmentHeader refParam = new EnlistmentHeader(base.enlistmentId, this.protocol);

            this.coordinatorService    = base.state.TwoPhaseCommitCoordinatorListener.CreateEndpointReference(refParam);
            this.participantProxy.From = this.coordinatorService;
        }
Example #5
0
        public void OnRootTransactionCreated()
        {
            base.enlistmentId = base.enlistment.LocalTransactionId;
            base.enlistment.RemoteTransactionId = CoordinationContext.CreateNativeIdentifier(base.enlistmentId);
            EnlistmentHeader refParam = new EnlistmentHeader(base.enlistmentId);

            this.coordinatorService = base.state.CompletionCoordinatorListener.CreateEndpointReference(refParam);
            base.ourContextManager  = new TransactionContextManager(base.state, base.enlistment.RemoteTransactionId);
            base.state.Lookup.AddTransactionContextManager(base.ourContextManager);
            base.ActivateTransactionContextManager(base.ourContextManager);
            base.AddToLookupTable();
            base.VerifyAndTraceEnlistmentOptions();
            base.TraceTransferEvent();
        }
 public static bool TryGetEnlistment(Message message, out Guid enlistmentId, out ControlProtocol protocol)
 {
     enlistmentId = Guid.Empty;
     protocol     = ControlProtocol.None;
     try
     {
         if (!EnlistmentHeader.ReadFrom(message, out enlistmentId, out protocol))
         {
             return(false);
         }
     }
     catch (InvalidEnlistmentHeaderException exception)
     {
         Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
         return(false);
     }
     return(true);
 }
        protected override void DeserializeExtended()
        {
            DebugTrace.TraceEnter(this, "DeserializeExtended");
            WsATv1LogEntryVersion version = (WsATv1LogEntryVersion)SerializationUtils.ReadByte(base.mem);

            if (!Enum.IsDefined(typeof(WsATv1LogEntryVersion), version))
            {
                Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Unsupported WsATv1LogEntryVersion");
            }
            WsATv1LogEntryFlags flags = (WsATv1LogEntryFlags)SerializationUtils.ReadByte(base.mem);

            if (DebugTrace.Verbose)
            {
                DebugTrace.Trace(TraceLevel.Verbose, "DeserializeExtended flags: {0}", flags);
            }
            this.CheckFlags(flags);
            if (((byte)(flags & WsATv1LogEntryFlags.OptimizedEndpointRepresentation)) == 0)
            {
                base.entry.Endpoint = SerializationUtils.ReadEndpointAddress(base.mem, this.protocolVersion);
                if (DebugTrace.Verbose)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Read endpoint address: {0}", base.entry.Endpoint.Uri);
                }
            }
            else
            {
                int    num;
                string str2;
                Guid   guid = SerializationUtils.ReadGuid(base.mem);
                if (DebugTrace.Verbose)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Read remote EnlistmentId: {0}", guid);
                }
                string str = SerializationUtils.ReadString(base.mem);
                if (DebugTrace.Verbose)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Read hostName: {0}", str);
                }
                if (((byte)(flags & WsATv1LogEntryFlags.UsesDefaultPort)) != 0)
                {
                    num = 0x944;
                }
                else
                {
                    num = SerializationUtils.ReadInt(base.mem);
                    if (DebugTrace.Verbose)
                    {
                        DebugTrace.Trace(TraceLevel.Verbose, "Read port: {0}", num);
                    }
                }
                if (((byte)(flags & WsATv1LogEntryFlags.UsesStandardCoordinatorAddressPath)) != 0)
                {
                    str2 = WsATv1LogEntrySerializer.StandardCoordinatorAddressPath(this.protocolVersion);
                }
                else if (((byte)(flags & WsATv1LogEntryFlags.UsesStandardParticipantAddressPath)) != 0)
                {
                    str2 = WsATv1LogEntrySerializer.StandardParticipantAddressPath(this.protocolVersion);
                }
                else
                {
                    str2 = SerializationUtils.ReadString(base.mem);
                    if (DebugTrace.Verbose)
                    {
                        DebugTrace.Trace(TraceLevel.Verbose, "Read address path: {0}", str2);
                    }
                }
                UriBuilder       builder = new UriBuilder(Uri.UriSchemeHttps, str, num, str2);
                EnlistmentHeader header  = new EnlistmentHeader(guid, ControlProtocol.Durable2PC);
                base.entry.Endpoint = new EndpointAddress(builder.Uri, new AddressHeader[] { header });
            }
            DebugTrace.TraceLeave(this, "DeserializeExtended");
        }