本文整理匯總了C#中Orleans.Runtime.Message.AddToCacheInvalidationHeader方法的典型用法代碼示例。如果您正苦於以下問題:C# Message.AddToCacheInvalidationHeader方法的具體用法?C# Message.AddToCacheInvalidationHeader怎麽用?C# Message.AddToCacheInvalidationHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Orleans.Runtime.Message
的用法示例。
在下文中一共展示了Message.AddToCacheInvalidationHeader方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TryForwardRequest
internal void TryForwardRequest(Message message, ActivationAddress oldAddress, ActivationAddress forwardingAddress, string failedOperation, Exception exc = null)
{
bool forwardingSucceded = true;
try
{
logger.Info(ErrorCode.Messaging_Dispatcher_TryForward,
String.Format("Trying to forward after {0}, ForwardCount = {1}. Message {2}.", failedOperation, message.ForwardCount, message));
MessagingProcessingStatisticsGroup.OnDispatcherMessageReRouted(message);
if (oldAddress != null)
{
message.AddToCacheInvalidationHeader(oldAddress);
}
forwardingSucceded = InsideRuntimeClient.Current.TryForwardMessage(message, forwardingAddress);
}
catch (Exception exc2)
{
forwardingSucceded = false;
exc = exc2;
}
finally
{
if (!forwardingSucceded)
{
var str = String.Format("Forwarding failed: tried to forward message {0} for {1} times after {2} to invalid activation. Rejecting now.",
message, message.ForwardCount, failedOperation);
logger.Warn(ErrorCode.Messaging_Dispatcher_TryForwardFailed, str, exc);
RejectMessage(message, Message.RejectionTypes.Transient, exc, str);
}
}
}
示例2: TryForwardRequest
internal void TryForwardRequest(Message message, ActivationAddress oldAddress, ActivationAddress forwardingAddress, string failedOperation, Exception exc = null)
{
bool forwardingSucceded = true;
try
{
logger.Info(ErrorCode.Messaging_Dispatcher_TryForward,
String.Format("Trying to forward after {0}, ForwardCount = {1}. Message {2}.", failedOperation, message.ForwardCount, message));
// if this message is from a different cluster and hit a non-existing activation
// in this cluster (which can happen due to stale cache or directory states)
// we forward it back to the original silo it came from in the original cluster,
// and target it to a fictional activation that is guaranteed to not exist.
// This ensures that the GSI protocol creates a new instance there instead of here.
if (forwardingAddress == null
&& message.TargetSilo != message.SendingSilo
&& !Silo.CurrentSilo.LocalGrainDirectory.IsSiloInCluster(message.SendingSilo))
{
message.IsReturnedFromRemoteCluster = true; // marks message to force invalidation of stale directory entry
forwardingAddress = ActivationAddress.NewActivationAddress(message.SendingSilo, message.TargetGrain);
logger.Info(ErrorCode.Messaging_Dispatcher_ReturnToOriginCluster,
String.Format("Forwarding back to origin cluster, to fictional activation {0}", message));
}
MessagingProcessingStatisticsGroup.OnDispatcherMessageReRouted(message);
if (oldAddress != null)
{
message.AddToCacheInvalidationHeader(oldAddress);
}
forwardingSucceded = InsideRuntimeClient.Current.TryForwardMessage(message, forwardingAddress);
}
catch (Exception exc2)
{
forwardingSucceded = false;
exc = exc2;
}
finally
{
if (!forwardingSucceded)
{
var str = String.Format("Forwarding failed: tried to forward message {0} for {1} times after {2} to invalid activation. Rejecting now.",
message, message.ForwardCount, failedOperation);
logger.Warn(ErrorCode.Messaging_Dispatcher_TryForwardFailed, str, exc);
RejectMessage(message, Message.RejectionTypes.Transient, exc, str);
}
}
}