當前位置: 首頁>>代碼示例>>C#>>正文


C# Message.SetTargetPlacement方法代碼示例

本文整理匯總了C#中Orleans.Runtime.Message.SetTargetPlacement方法的典型用法代碼示例。如果您正苦於以下問題:C# Message.SetTargetPlacement方法的具體用法?C# Message.SetTargetPlacement怎麽用?C# Message.SetTargetPlacement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Orleans.Runtime.Message的用法示例。


在下文中一共展示了Message.SetTargetPlacement方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddressMessage

        /// <summary>
        /// Resolve target address for a message
        /// - use transaction info
        /// - check ordering info in message & sending activation
        /// - use sender's placement strategy
        /// </summary>
        /// <param name="message"></param>
        /// <returns>Resolve when message is addressed (modifies message fields)</returns>
        private async Task AddressMessage(Message message)
        {
            var targetAddress = message.TargetAddress;
            if (targetAddress.IsComplete) return;

            // placement strategy is determined by searching for a specification. first, we check for a strategy associated with the grain reference,
            // second, we check for a strategy associated with the target's interface. third, we check for a strategy associated with the activation sending the
            // message.
            var strategy = targetAddress.Grain.IsGrain ? catalog.GetGrainPlacementStrategy(targetAddress.Grain) : null;
            var placementResult = await PlacementDirectorsManager.Instance.SelectOrAddActivation(
                message.SendingAddress, message.TargetGrain, InsideRuntimeClient.Current.Catalog, strategy);

            if (placementResult.IsNewPlacement && targetAddress.Grain.IsClient)
            {
                logger.Error(ErrorCode.Dispatcher_AddressMsg_UnregisteredClient, String.Format("AddressMessage could not find target for client pseudo-grain {0}", message));
                throw new KeyNotFoundException(String.Format("Attempting to send a message {0} to an unregistered client pseudo-grain {1}", message, targetAddress.Grain));
            }

            message.SetTargetPlacement(placementResult);
            if (placementResult.IsNewPlacement)
            {
                CounterStatistic.FindOrCreate(StatisticNames.DISPATCHER_NEW_PLACEMENT).Increment();
            }
            if (logger.IsVerbose2) logger.Verbose2(ErrorCode.Dispatcher_AddressMsg_SelectTarget, "AddressMessage Placement SelectTarget {0}", message);
       }
開發者ID:andrewalex,項目名稱:orleans,代碼行數:33,代碼來源:Dispatcher.cs


注:本文中的Orleans.Runtime.Message.SetTargetPlacement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。