本文整理汇总了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);
}