コード例 #1
0
 private CoordinationContext CreateCoordinationContext(WsatTransactionInfo info)
 {
     CoordinationContext coordinationContext;
     Microsoft.Transactions.Wsat.Messaging.CreateCoordinationContext cccMessage = new Microsoft.Transactions.Wsat.Messaging.CreateCoordinationContext(this.protocolVersion) {
         CurrentContext = info.Context,
         IssuedToken = info.IssuedToken
     };
     try
     {
         using (new OperationContextScope(null))
         {
             coordinationContext = this.Enlist(ref cccMessage).CoordinationContext;
         }
     }
     catch (WsatFaultException exception)
     {
         DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Error);
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TransactionException(System.ServiceModel.SR.GetString("UnmarshalTransactionFaulted", new object[] { exception.Message }), exception));
     }
     catch (WsatSendFailureException exception2)
     {
         DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Error);
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TransactionManagerCommunicationException(System.ServiceModel.SR.GetString("TMCommunicationError"), exception2));
     }
     return coordinationContext;
 }
 private CreateCoordinationContextMessage CreateCreateCoordinationContextMessage(ref CreateCoordinationContext create)
 {
     CreateCoordinationContextMessage message = new CreateCoordinationContextMessage(base.messageVersion, ref create);
     if (create.IssuedToken != null)
     {
         CoordinationServiceSecurity.AddIssuedToken(message, create.IssuedToken);
     }
     return message;
 }
 public IAsyncResult BeginSendCreateCoordinationContext(ref CreateCoordinationContext create, AsyncCallback callback, object state)
 {
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Sending CreateCoordinationContext to {0}", base.to.Uri);
     }
     Message message = this.CreateCreateCoordinationContextMessage(ref create);
     return base.BeginSendRequest(message, callback, state);
 }
コード例 #4
0
        public IAsyncResult BeginSendCreateCoordinationContext(ref CreateCoordinationContext create, AsyncCallback callback, object state)
        {
            if (DebugTrace.Verbose)
            {
                DebugTrace.Trace(TraceLevel.Verbose, "Sending CreateCoordinationContext to {0}", base.to.Uri);
            }
            Message message = this.CreateCreateCoordinationContextMessage(ref create);

            return(base.BeginSendRequest(message, callback, state));
        }
 public CreateCoordinationContextResponse SendCreateCoordinationContext(ref CreateCoordinationContext create)
 {
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Sending CreateCoordinationContext to {0}", base.to.Uri);
     }
     Message message = this.CreateCreateCoordinationContextMessage(ref create);
     Message message2 = base.SendRequest(message, base.coordinationStrings.CreateCoordinationContextResponseAction);
     using (message2)
     {
         if (DebugTrace.Verbose)
         {
             DebugTrace.Trace(TraceLevel.Verbose, "Dispatching CreateCoordinationContextResponse reply");
             if (DebugTrace.Pii)
             {
                 DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message2));
             }
         }
         return new CreateCoordinationContextResponse(message2, base.protocolVersion);
     }
 }
 public void CreateCoordinationContext(Message message, Microsoft.Transactions.Wsat.Messaging.RequestAsyncResult result)
 {
     Microsoft.Transactions.Wsat.Messaging.CreateCoordinationContext create = new Microsoft.Transactions.Wsat.Messaging.CreateCoordinationContext(message, this.state.ProtocolVersion);
     CoordinationContext currentContext = create.CurrentContext;
     if (currentContext == null)
     {
         CompletionEnlistment completion = new CompletionEnlistment(this.state);
         completion.StateMachine.Enqueue(new MsgCreateTransactionEvent(completion, ref create, result));
     }
     else
     {
         TransactionContextManager contextManager = this.state.Lookup.FindTransactionContextManager(currentContext.Identifier);
         if (contextManager == null)
         {
             bool flag;
             contextManager = new TransactionContextManager(this.state, currentContext.Identifier);
             contextManager = this.state.Lookup.FindOrAddTransactionContextManager(contextManager, out flag);
         }
         contextManager.StateMachine.Enqueue(new TransactionContextEnlistTransactionEvent(contextManager, ref create, result));
     }
 }
コード例 #7
0
        public CreateCoordinationContextResponse SendCreateCoordinationContext(ref CreateCoordinationContext create)
        {
            if (DebugTrace.Verbose)
            {
                DebugTrace.Trace(TraceLevel.Verbose, "Sending CreateCoordinationContext to {0}", base.to.Uri);
            }
            Message message  = this.CreateCreateCoordinationContextMessage(ref create);
            Message message2 = base.SendRequest(message, base.coordinationStrings.CreateCoordinationContextResponseAction);

            using (message2)
            {
                if (DebugTrace.Verbose)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Dispatching CreateCoordinationContextResponse reply");
                    if (DebugTrace.Pii)
                    {
                        DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message2));
                    }
                }
                return(new CreateCoordinationContextResponse(message2, base.protocolVersion));
            }
        }
 public MsgEnlistTransactionEvent(CoordinatorEnlistment coordinator, ref CreateCoordinationContext create, RequestAsyncResult result) : base(coordinator)
 {
     this.create = create;
     this.result = result;
 }
コード例 #9
0
        //=============================================================================================
        // The demand is not added now (in 4.5), to avoid a breaking change. To be considered in the next version.
        /*
        [PermissionSet(SecurityAction.Demand, Unrestricted = true)] // because we call code from a non-APTCA assembly; WSATs are not supported in partial trust, so customers should not be broken by this demand
        */
        CreateCoordinationContextResponse Enlist(ref CreateCoordinationContext cccMessage)
        {
            int attempts = 0;
            while (true)
            {
                ActivationProxy proxy = GetActivationProxy();
                EndpointAddress address = proxy.To;

                EndpointAddress localActivationService = this.wsatConfig.LocalActivationService(this.protocolVersion);
                EndpointAddress remoteActivationService = this.wsatConfig.RemoteActivationService(this.protocolVersion);

                try
                {
                    return proxy.SendCreateCoordinationContext(ref cccMessage);
                }
                catch (WsatSendFailureException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);

                    // Don't retry if we're not likely to succeed on the next pass
                    Exception inner = e.InnerException;
                    if (inner is TimeoutException ||
                        inner is QuotaExceededException ||
                        inner is FaultException)
                        throw;

                    // Give up after 10 attempts
                    if (attempts > 10)
                        throw;

                    if (attempts > 5 &&
                        remoteActivationService != null &&
                        ReferenceEquals(address, localActivationService))
                    {
                        // Switch over to the remote activation service.
                        // In clustered scenarios this uses the cluster name,
                        // so it should always work if the resource is online
                        // This covers the case where we were using a local cluster
                        // resource which failed over to another node
                        address = remoteActivationService;
                    }
                }
                finally
                {
                    proxy.Release();
                }

                TryStartMsdtcService();

                // We need to refresh our proxy here because the channel is sessionful
                // and may simply decided to enter the faulted state if something fails.
                RefreshActivationProxy(address);

                // Don't spin
                Thread.Sleep(0);
                attempts++;
            }
        }
コード例 #10
0
        //=============================================================================================
        // The demand is not added now (in 4.5), to avoid a breaking change. To be considered in the next version.
        /*
        // We demand full trust because we use CreateCoordinationContext from a non-APTCA assembly and the CreateCoordinationContext constructor does an Environment.FailFast 
        // if the argument is invalid. It's recommended to not let partially trusted callers to bring down the process.
        // WSATs are not supported in partial trust, so customers should not be broken by this demand.
        [PermissionSet(SecurityAction.Demand, Unrestricted = true)]
        */
        CoordinationContext CreateCoordinationContext(WsatTransactionInfo info)
        {
            CreateCoordinationContext cccMessage = new CreateCoordinationContext(this.protocolVersion);
            cccMessage.CurrentContext = info.Context;
            cccMessage.IssuedToken = info.IssuedToken;

            try
            {
                // This was necessary during some portions of WCF 1.0 development
                // It is probably not needed now. However, it seems conceptually 
                // solid to separate this operation from the incoming app message as 
                // much as possible.  There have also been enough ServiceModel bugs in 
                // this area that it does not seem wise to remove this at the moment
                // (2006/3/30, WCF 1.0 RC1 milestone)
                using (new OperationContextScope((OperationContext)null))
                {
                    return Enlist(ref cccMessage).CoordinationContext;
                }
            }
            catch (WsatFaultException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new TransactionException(SR.GetString(SR.UnmarshalTransactionFaulted, e.Message), e));
            }
            catch (WsatSendFailureException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new TransactionManagerCommunicationException(SR.GetString(SR.TMCommunicationError), e));
            }
        }
 public MsgCreateTransactionEvent(CompletionEnlistment completion, ref CreateCoordinationContext create, RequestAsyncResult result) : base(completion)
 {
     this.create = create;
     this.result = result;
 }
 public CreateCoordinationContextMessage(MessageVersion version, ref CreateCoordinationContext create) : base(CoordinationStrings.Version(create.ProtocolVersion).CreateCoordinationContextAction, version)
 {
     this.create = create;
 }
コード例 #13
0
        private CreateCoordinationContextMessage CreateCreateCoordinationContextMessage(ref CreateCoordinationContext create)
        {
            CreateCoordinationContextMessage message = new CreateCoordinationContextMessage(base.messageVersion, ref create);

            if (create.IssuedToken != null)
            {
                CoordinationServiceSecurity.AddIssuedToken(message, create.IssuedToken);
            }
            return(message);
        }