예제 #1
0
 private void ProcessRequestToStuckActivation(
     Message message,
     ActivationData activationData,
     string failedOperation)
 {
     scheduler.RunOrQueueTask(
         async() =>
     {
         await catalog.DeactivateStuckActivation(activationData);
         TryForwardRequest(message, activationData.Address, activationData.ForwardingAddress, failedOperation);
     },
         catalog)
     .Ignore();
 }
예제 #2
0
        /// <summary>
        /// Enqueue message for local handling after transaction completes
        /// </summary>
        /// <param name="message"></param>
        /// <param name="targetActivation"></param>
        private void EnqueueRequest(Message message, ActivationData targetActivation)
        {
            var overloadException = targetActivation.CheckOverloaded(logger);

            if (overloadException != null)
            {
                MessagingProcessingStatisticsGroup.OnDispatcherMessageProcessedError(message, "Overload2");
                RejectMessage(message, Message.RejectionTypes.Overloaded, overloadException, "Target activation is overloaded " + targetActivation);
                return;
            }

            switch (targetActivation.EnqueueMessage(message))
            {
            case ActivationData.EnqueueMessageResult.Success:
                // Great, nothing to do
                break;

            case ActivationData.EnqueueMessageResult.ErrorInvalidActivation:
                ProcessRequestToInvalidActivation(message, targetActivation.Address, targetActivation.ForwardingAddress, "EnqueueRequest");
                break;

            case ActivationData.EnqueueMessageResult.ErrorActivateFailed:
                ProcessRequestToInvalidActivation(message, targetActivation.Address, targetActivation.ForwardingAddress, "EnqueueRequest", rejectMessages: true);
                break;

            case ActivationData.EnqueueMessageResult.ErrorStuckActivation:
                // Avoid any new call to this activation
                catalog.DeactivateStuckActivation(targetActivation);
                ProcessRequestToInvalidActivation(message, targetActivation.Address, targetActivation.ForwardingAddress, "EnqueueRequest - blocked grain");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            // Dont count this as end of processing. The message will come back after queueing via HandleIncomingRequest.

#if DEBUG
            // This is a hot code path, so using #if to remove diags from Release version
            // Note: Caller already holds lock on activation
            if (logger.IsEnabled(LogLevel.Trace))
            {
                logger.Trace(ErrorCode.Dispatcher_EnqueueMessage,
                             "EnqueueMessage for {0}: targetActivation={1}", message.TargetActivation, targetActivation.DumpStatus());
            }
#endif
        }