本文整理汇总了C#中Orleans.Runtime.Message.DropExpiredMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Message.DropExpiredMessage方法的具体用法?C# Message.DropExpiredMessage怎么用?C# Message.DropExpiredMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orleans.Runtime.Message
的用法示例。
在下文中一共展示了Message.DropExpiredMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpireMessageIfExpired
private static bool ExpireMessageIfExpired(Message message, MessagingStatisticsGroup.Phase phase)
{
if (message.IsExpired)
{
message.DropExpiredMessage(phase);
return true;
}
return false;
}
示例2: Invoke
internal async Task Invoke(IAddressable target, IInvokable invokable, Message message)
{
try
{
// Don't process messages that have already timed out
if (message.IsExpired)
{
message.DropExpiredMessage(MessagingStatisticsGroup.Phase.Invoke);
return;
}
RequestContext.Import(message.RequestContextData);
if (Config.Globals.PerformDeadlockDetection && !message.TargetGrain.IsSystemTarget)
{
UpdateDeadlockInfoInRequestContext(new RequestInvocationHistory(message));
// RequestContext is automatically saved in the msg upon send and propagated to the next hop
// in RuntimeClient.CreateMessage -> RequestContext.ExportToMessage(message);
}
object resultObject;
try
{
var request = (InvokeMethodRequest) message.BodyObject;
var invoker = invokable.GetInvoker(request.InterfaceId, message.GenericGrainType);
if (invoker is IGrainExtensionMethodInvoker
&& !(target is IGrainExtension))
{
// We are trying the invoke a grain extension method on a grain
// -- most likely reason is that the dynamic extension is not installed for this grain
// So throw a specific exception here rather than a general InvalidCastException
var error = String.Format(
"Extension not installed on grain {0} attempting to invoke type {1} from invokable {2}",
target.GetType().FullName, invoker.GetType().FullName, invokable.GetType().FullName);
var exc = new GrainExtensionNotInstalledException(error);
string extraDebugInfo = null;
#if DEBUG
extraDebugInfo = new StackTrace().ToString();
#endif
logger.Warn(ErrorCode.Stream_ExtensionNotInstalled,
string.Format("{0} for message {1} {2}", error, message, extraDebugInfo), exc);
throw exc;
}
// If the target has a grain-level interceptor or there is a silo-level interceptor, intercept the call.
var shouldCallSiloWideInterceptor = SiloProviderRuntime.Instance.GetInvokeInterceptor() != null && target is IGrain;
var intercepted = target as IGrainInvokeInterceptor;
if (intercepted != null || shouldCallSiloWideInterceptor)
{
// Fetch the method info for the intercepted call.
var implementationInvoker =
invocationMethodInfoMap.GetInterceptedMethodInvoker(target.GetType(), request.InterfaceId,
invoker);
var methodInfo = implementationInvoker.GetMethodInfo(request.MethodId);
if (shouldCallSiloWideInterceptor)
{
// There is a silo-level interceptor and possibly a grain-level interceptor.
var runtime = SiloProviderRuntime.Instance;
resultObject =
await runtime.CallInvokeInterceptor(methodInfo, request, target, implementationInvoker);
}
else
{
// The grain has an interceptor, but there is no silo-wide interceptor.
resultObject = await intercepted.Invoke(methodInfo, request, invoker);
}
}
else
{
// The call is not intercepted.
resultObject = await invoker.Invoke(target, request);
}
}
catch (Exception exc1)
{
if (invokeExceptionLogger.IsVerbose || message.Direction == Message.Directions.OneWay)
{
invokeExceptionLogger.Warn(ErrorCode.GrainInvokeException,
"Exception during Grain method call of message: " + message, exc1);
}
if (message.Direction != Message.Directions.OneWay)
{
SafeSendExceptionResponse(message, exc1);
}
return;
}
if (message.Direction == Message.Directions.OneWay) return;
SafeSendResponse(message, resultObject);
}
catch (Exception exc2)
{
logger.Warn(ErrorCode.Runtime_Error_100329, "Exception during Invoke of message: " + message, exc2);
if (message.Direction != Message.Directions.OneWay)
SafeSendExceptionResponse(message, exc2);
}
}
示例3: ReceiveMessage
/// <summary>
/// Receive a new message:
/// - validate order constraints, queue (or possibly redirect) if out of order
/// - validate transactions constraints
/// - invoke handler if ready, otherwise enqueue for later invocation
/// </summary>
/// <param name="message"></param>
public void ReceiveMessage(Message message)
{
MessagingProcessingStatisticsGroup.OnDispatcherMessageReceive(message);
// Don't process messages that have already timed out
if (message.IsExpired)
{
logger.Warn(ErrorCode.Dispatcher_DroppingExpiredMessage, "Dropping an expired message: {0}", message);
MessagingProcessingStatisticsGroup.OnDispatcherMessageProcessedError(message, "Expired");
message.DropExpiredMessage(MessagingStatisticsGroup.Phase.Dispatch);
return;
}
// check if its targeted at a new activation
if (message.TargetGrain.IsSystemTarget)
{
MessagingProcessingStatisticsGroup.OnDispatcherMessageProcessedError(message, "ReceiveMessage on system target.");
throw new InvalidOperationException("Dispatcher was called ReceiveMessage on system target for " + message);
}
if (errorInjection && ShouldInjectError(message))
{
if (logger.IsVerbose) logger.Verbose(ErrorCode.Dispatcher_InjectingRejection, "Injecting a rejection");
MessagingProcessingStatisticsGroup.OnDispatcherMessageProcessedError(message, "ErrorInjection");
RejectMessage(message, Message.RejectionTypes.Unrecoverable, null, "Injected rejection");
return;
}
try
{
Task ignore;
ActivationData target = catalog.GetOrCreateActivation(
message.TargetAddress,
message.IsNewPlacement,
message.NewGrainType,
message.GenericGrainType,
message.RequestContextData,
out ignore);
if (ignore != null)
{
ignore.Ignore();
}
if (message.Direction == Message.Directions.Response)
{
ReceiveResponse(message, target);
}
else // Request or OneWay
{
// Silo is always capable to accept a new request. It's up to the activation to handle its internal state.
// If activation is shutting down, it will queue and later forward this request.
ReceiveRequest(message, target);
}
}
catch (Exception ex)
{
try
{
MessagingProcessingStatisticsGroup.OnDispatcherMessageProcessedError(message, "Non-existent activation");
var nea = ex as Catalog.NonExistentActivationException;
if (nea == null)
{
var str = String.Format("Error creating activation for {0}. Message {1}", message.NewGrainType, message);
logger.Error(ErrorCode.Dispatcher_ErrorCreatingActivation, str, ex);
throw new OrleansException(str, ex);
}
if (nea.IsStatelessWorker)
{
if (logger.IsVerbose) logger.Verbose(ErrorCode.Dispatcher_Intermediate_GetOrCreateActivation,
String.Format("Intermediate StatelessWorker NonExistentActivation for message {0}", message), ex);
}
else
{
logger.Info(ErrorCode.Dispatcher_Intermediate_GetOrCreateActivation,
String.Format("Intermediate NonExistentActivation for message {0}", message), ex);
}
ActivationAddress nonExistentActivation = nea.NonExistentActivation;
if (message.Direction != Message.Directions.Response)
{
// Un-register the target activation so we don't keep getting spurious messages.
// The time delay (one minute, as of this writing) is to handle the unlikely but possible race where
// this request snuck ahead of another request, with new placement requested, for the same activation.
// If the activation registration request from the new placement somehow sneaks ahead of this un-registration,
// we want to make sure that we don't un-register the activation we just created.
// We would add a counter here, except that there's already a counter for this in the Catalog.
// Note that this has to run in a non-null scheduler context, so we always queue it to the catalog's context
if (config.Globals.DirectoryLazyDeregistrationDelay > TimeSpan.Zero)
{
Scheduler.QueueWorkItem(new ClosureWorkItem(
//.........这里部分代码省略.........
示例4: SendResponse
private void SendResponse(Message request, Response response)
{
// Don't process messages that have already timed out
if (request.IsExpired)
{
request.DropExpiredMessage(MessagingStatisticsGroup.Phase.Respond);
return;
}
dispatcher.SendResponse(request, response);
}
示例5: Invoke
internal async Task Invoke(IAddressable target, IInvokable invokable, Message message)
{
try
{
// Don't process messages that have already timed out
if (message.IsExpired)
{
message.DropExpiredMessage(MessagingStatisticsGroup.Phase.Invoke);
return;
}
//MessagingProcessingStatisticsGroup.OnRequestProcessed(message, "Invoked");
if (Message.WriteMessagingTraces)
message.AddTimestamp(Message.LifecycleTag.InvokeIncoming);
RequestContext.ImportFromMessage(message);
if (Config.Globals.PerformDeadlockDetection && !message.TargetGrain.IsSystemTarget)
{
UpdateDeadlockInfoInRequestContext(new RequestInvocationHistory(message));
// RequestContext is automatically saved in the msg upon send and propagated to the next hop
// in RuntimeClient.CreateMessage -> RequestContext.ExportToMessage(message);
}
var invoker = invokable.GetInvoker(message.InterfaceId, message.GenericGrainType);
object resultObject;
try
{
var request = (InvokeMethodRequest) message.BodyObject;
if (invoker is IGrainExtensionMethodInvoker
&& !(target is IGrainExtension))
{
// We are trying the invoke a grain extension method on a grain
// -- most likely reason is that the dynamic extension is not installed for this grain
// So throw a specific exception here rather than a general InvalidCastException
var error = String.Format(
"Extension not installed on grain {0} attempting to invoke type {1} from invokable {2}",
target.GetType().FullName, invoker.GetType().FullName, invokable.GetType().FullName);
var exc = new GrainExtensionNotInstalledException(error);
string extraDebugInfo = null;
#if DEBUG
extraDebugInfo = new StackTrace().ToString();
#endif
logger.Warn(ErrorCode.Stream_ExtensionNotInstalled,
string.Format("{0} for message {1} {2}", error, message, extraDebugInfo), exc);
throw exc;
}
resultObject = await invoker.Invoke(target, request.InterfaceId, request.MethodId, request.Arguments);
}
catch (Exception exc1)
{
if (invokeExceptionLogger.IsVerbose || message.Direction == Message.Directions.OneWay)
{
invokeExceptionLogger.Warn(ErrorCode.GrainInvokeException,
"Exception during Grain method call of message: " + message, exc1);
}
if (message.Direction != Message.Directions.OneWay)
{
SafeSendExceptionResponse(message, exc1);
}
return;
}
if (message.Direction == Message.Directions.OneWay) return;
SafeSendResponse(message, resultObject);
}
catch (Exception exc2)
{
logger.Warn(ErrorCode.Runtime_Error_100329, "Exception during Invoke of message: " + message, exc2);
if (message.Direction != Message.Directions.OneWay)
SafeSendExceptionResponse(message, exc2);
}
}