コード例 #1
0
        public static bool TryGet(Message message, out ReceiveContext property)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
            }

            bool result = TryGet(message.Properties, out property);
            if (result && FxTrace.Trace.IsEnd2EndActivityTracingEnabled && property.eventTraceActivity == null)
            {
                property.eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(message);
            }

            return result;
        }
コード例 #2
0
        public static bool TryGet(MessageProperties properties, out ReceiveContext property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            property = null;
            object foundProperty;
            if (properties.TryGetValue(Name, out foundProperty))
            {
                property = (ReceiveContext)foundProperty;
                return true;
            }
            return false;
        }
コード例 #3
0
        public MsmqInputSessionChannel(MsmqInputSessionChannelListener listener, Transaction associatedTx, ReceiveContext sessiongramReceiveContext)
            : base(listener, new EndpointAddress(listener.Uri))
        {
            this.session = new InputSession();
            this.incompleteMessageCount = 0;

            if (sessiongramReceiveContext == null)
            {
                this.receiveContextEnabled = false;

                // only enlist if we are running in a non-receive context mode
                this.associatedTx = associatedTx;
                this.associatedTx.EnlistVolatile(new TransactionEnlistment(this, this.associatedTx), EnlistmentOptions.None);
            }
            else
            {
                //ignore the ambient transaction if any
                this.receiveContextEnabled = true;
                this.sessiongramReceiveContext = sessiongramReceiveContext;
                this.sessiongramDoomed = false;
            }
        }
コード例 #4
0
 public static void EnsureReceiveContextAbandonOnTransactionRollback(ReceiveContext receiveContext, Transaction transaction, ChannelHandler channelHandler)
 {
     new TransactionOutcomeListener(receiveContext, transaction, channelHandler);
 }
コード例 #5
0
 public TransactionOutcomeListener(ReceiveContext receiveContext, Transaction transaction, ChannelHandler handler)
 {
     this.receiveContext = receiveContext;
     transaction.TransactionCompleted += new TransactionCompletedEventHandler(this.OnTransactionComplete);
     this.channelHandler = handler;
 }
コード例 #6
0
            public AcknowledgementCompleteAsyncResult(
                ReceiveContext receiveContext,
                TimeSpan timeout,
                ref MessageRpc rpc,
                Transaction transaction,
                AsyncCallback callback,
                object state) : base(callback, state)
            {
                this.receiveContext = receiveContext;
                this.currentTransaction = transaction;
                this.channelHandler = rpc.channelHandler;
                this.resumableRPC = rpc.Pause();

                bool completeThrew = true;
                try
                {
                    bool completed = this.Complete(timeout);
                    completeThrew = false;

                    if (completed)
                    {
                        this.resumableRPC = null;
                        rpc.UnPause();
                        this.Complete(true);
                    }
                }
                finally
                {
                    if (completeThrew)
                    {
                        rpc.UnPause();
                    }
                }
            }
コード例 #7
0
 ReceiveContextRPCFacet(ReceiveContext receiveContext)
 {
     this.receiveContext = receiveContext;
 }
コード例 #8
0
 internal ReceiveContextBusyCountWrapper(ReceiveContext context)
 {
     this.wrappedContext = context;
     this.wrappedContext.Faulted += new EventHandler(OnWrappedContextFaulted);
     AspNetEnvironment.Current.IncrementBusyCount();
     if (AspNetEnvironment.Current.TraceIncrementBusyCountIsEnabled())
     {
         AspNetEnvironment.Current.TraceIncrementBusyCount(this.GetType().FullName);
     }
     Interlocked.Increment(ref busyCount);
 }
コード例 #9
0
 public static IAsyncResult BeginProcessReceiveContext(WorkflowOperationContext context, ReceiveContext receiveContext, AsyncCallback callback, object state)
 {
     return new ReceiveContextAsyncResult(context, receiveContext, callback, state);
 }
コード例 #10
0
        internal static IInputSessionChannel DecodeTransportSessiongram(MsmqInputSessionChannelListener listener, MsmqInputMessage msmqMessage, MsmqMessageProperty messageProperty, MsmqReceiveContextLockManager receiveContextManager)
        {
            using (MsmqDiagnostics.BoundReceiveBytesOperation())
            {
                int               num4;
                long              num1              = msmqMessage.LookupId.Value;
                int               size              = msmqMessage.BodyLength.Value;
                int               offset            = 0;
                byte[]            incoming          = msmqMessage.Body.Buffer;
                MsmqReceiveHelper msmqReceiveHelper = listener.MsmqReceiveHelper;
                ServerModeDecoder modeDecoder       = new ServerModeDecoder();
                try
                {
                    ReadServerMode(listener, modeDecoder, incoming, messageProperty.LookupId, ref offset, ref size);
                }
                catch (ProtocolException exception)
                {
                    msmqReceiveHelper.FinalDisposition(messageProperty);
                    throw listener.NormalizePoisonException(messageProperty.LookupId, exception);
                }
                if (modeDecoder.Mode != FramingMode.Simplex)
                {
                    msmqReceiveHelper.FinalDisposition(messageProperty);
                    throw listener.NormalizePoisonException(messageProperty.LookupId, new ProtocolException(System.ServiceModel.SR.GetString("MsmqBadFrame")));
                }
                MsmqInputSessionChannel channel  = null;
                ServerSessionDecoder    decoder2 = new ServerSessionDecoder(0L, 0x800, 0x100);
                try
                {
                    do
                    {
                        if (size <= 0)
                        {
                            throw listener.NormalizePoisonException(messageProperty.LookupId, decoder2.CreatePrematureEOFException());
                        }
                        int num3 = decoder2.Decode(incoming, offset, size);
                        offset += num3;
                        size   -= num3;
                    }while (ServerSessionDecoder.State.EnvelopeStart != decoder2.CurrentState);
                }
                catch (ProtocolException exception2)
                {
                    msmqReceiveHelper.FinalDisposition(messageProperty);
                    throw listener.NormalizePoisonException(messageProperty.LookupId, exception2);
                }
                MessageEncoder encoder = listener.MessageEncoderFactory.CreateSessionEncoder();
                if (!encoder.IsContentTypeSupported(decoder2.ContentType))
                {
                    msmqReceiveHelper.FinalDisposition(messageProperty);
                    throw listener.NormalizePoisonException(messageProperty.LookupId, new ProtocolException(System.ServiceModel.SR.GetString("MsmqBadContentType")));
                }
                ReceiveContext sessiongramReceiveContext = null;
                if (msmqReceiveHelper.MsmqReceiveParameters.ReceiveContextSettings.Enabled)
                {
                    sessiongramReceiveContext = receiveContextManager.CreateMsmqReceiveContext(msmqMessage.LookupId.Value);
                }
                channel = new MsmqInputSessionChannel(listener, Transaction.Current, sessiongramReceiveContext);
                Message item = DecodeSessiongramMessage(listener, channel, encoder, messageProperty, incoming, offset, decoder2.EnvelopeSize);
                SecurityMessageProperty property = null;
                try
                {
                    property = listener.ValidateSecurity(msmqMessage);
                }
                catch (Exception exception3)
                {
                    if (Fx.IsFatal(exception3))
                    {
                        throw;
                    }
                    channel.FaultChannel();
                    msmqReceiveHelper.FinalDisposition(messageProperty);
                    throw listener.NormalizePoisonException(messageProperty.LookupId, exception3);
                }
                if (property != null)
                {
                    item.Properties.Security = property;
                }
                item.Properties["MsmqMessageProperty"] = messageProperty;
                channel.EnqueueAndDispatch(item);
                listener.RaiseMessageReceived();
Label_01F6:
                try
                {
                    if (size <= 0)
                    {
                        channel.FaultChannel();
                        msmqReceiveHelper.FinalDisposition(messageProperty);
                        throw listener.NormalizePoisonException(messageProperty.LookupId, decoder2.CreatePrematureEOFException());
                    }
                    num4 = decoder2.Decode(incoming, offset, size);
                }
                catch (ProtocolException exception4)
                {
                    channel.FaultChannel();
                    msmqReceiveHelper.FinalDisposition(messageProperty);
                    throw listener.NormalizePoisonException(messageProperty.LookupId, exception4);
                }
                offset += num4;
                size   -= num4;
                if (ServerSessionDecoder.State.End != decoder2.CurrentState)
                {
                    if (ServerSessionDecoder.State.EnvelopeStart == decoder2.CurrentState)
                    {
                        item = DecodeSessiongramMessage(listener, channel, encoder, messageProperty, incoming, offset, decoder2.EnvelopeSize);
                        if (property != null)
                        {
                            item.Properties.Security = (SecurityMessageProperty)property.CreateCopy();
                        }
                        item.Properties["MsmqMessageProperty"] = messageProperty;
                        channel.EnqueueAndDispatch(item);
                        listener.RaiseMessageReceived();
                    }
                    goto Label_01F6;
                }
                channel.Shutdown();
                MsmqDiagnostics.SessiongramReceived(channel.Session.Id, msmqMessage.MessageId, channel.InternalPendingItems);
                return(channel);
            }
        }
コード例 #11
0
 public WaitAndContinueOperationAsyncResult(ReceiveContext receiveContext, TimeSpan timeout, AsyncCallback callback, object state)
     : base(callback, state)
 {
     this.ReceiveContext = receiveContext;
     this.TimeoutHelper = new TimeoutHelper(timeout);
 }
コード例 #12
0
 public EnlistmentNotifications(ReceiveContext context)
 {
     this.context = context;
 }
コード例 #13
0
 public CompleteAsyncResult(ReceiveContext receiveContext, TimeSpan timeout, AsyncCallback callback, object state)
     : base(receiveContext, timeout, callback, state)
 {
     this.transaction = Transaction.Current;
     this.Begin();
 }
コード例 #14
0
 public AbandonAsyncResult(ReceiveContext receiveContext, Exception exception, TimeSpan timeout, AsyncCallback callback, object state)
     : base(receiveContext, timeout, callback, state)
 {
     this.exception = exception;
     base.Begin();
 }
コード例 #15
0
            ReceiveContextAsyncResult(WorkflowOperationContext context, ReceiveContext receiveContext, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.context = context;
                this.receiveContext = receiveContext;

                if (ProcessReceiveContext())
                {
                    base.Complete(true);
                }
            }
コード例 #16
0
 public ReceiveContextTransactionEnlistment(MsmqInputSessionChannel channel, Transaction transaction, ReceiveContext receiveContext)
 {
     this.channel = channel;
     this.transaction = transaction;
     this.sessiongramReceiveContext = receiveContext;
 }
コード例 #17
0
 public static bool TryGet(Message message, out ReceiveContext property)
 {
     if (message == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
     }
     return TryGet(message.Properties, out property);
 }