/// <summary> /// Check if we can locally accept this message. /// Redirects if it can't be accepted. /// </summary> /// <param name="message"></param> /// <param name="targetActivation"></param> private void ReceiveRequest(Message message, ActivationData targetActivation) { lock (targetActivation) { if (!ActivationMayAcceptRequest(targetActivation, message)) { // Check for deadlock before Enqueueing. if (schedulingOptions.PerformDeadlockDetection && !message.TargetGrain.IsSystemTarget()) { try { CheckDeadlock(message); } catch (DeadlockException exc) { // Record that this message is no longer flowing through the system this.messagingTrace.OnDispatcherDetectedDeadlock(message, targetActivation, exc); // We want to send DeadlockException back as an application exception, rather than as a system rejection. SendResponse(message, Response.ExceptionResponse(exc)); return; } } EnqueueRequest(message, targetActivation); } else { HandleIncomingRequest(message, targetActivation); } } }
/// <summary> /// Check if we can locally accept this message. /// Redirects if it can't be accepted. /// </summary> /// <param name="message"></param> /// <param name="targetActivation"></param> private void ReceiveRequest(Message message, ActivationData targetActivation) { lock (targetActivation) { if (!ActivationMayAcceptRequest(targetActivation, message)) { // Check for deadlock before Enqueueing. if (schedulingOptions.PerformDeadlockDetection && !message.TargetGrain.IsSystemTarget) { try { CheckDeadlock(message); } catch (DeadlockException exc) { // Record that this message is no longer flowing through the system MessagingProcessingStatisticsGroup.OnDispatcherMessageProcessedError(message, "Deadlock"); logger.Warn(ErrorCode.Dispatcher_DetectedDeadlock, "Detected Application Deadlock: {0}", exc.Message); // We want to send DeadlockException back as an application exception, rather than as a system rejection. SendResponse(message, Response.ExceptionResponse(exc)); return; } } EnqueueRequest(message, targetActivation); } else { HandleIncomingRequest(message, targetActivation); } } }
public Message CreatePromptExceptionResponse(Exception exception) { return(new Message(Category, Directions.Response) { Result = ResponseTypes.Error, BodyObject = Response.ExceptionResponse(exception) }); }
public Message CreatePromptTimeoutResponse(string errorMsg) { return(new Message(Category, Directions.Response) { Result = ResponseTypes.Error, BodyObject = Response.ExceptionResponse(new TimeoutException(errorMsg)) }); }
public void OnTimeout() { if (alreadyFired) { return; } var msg = this.Message; // Local working copy lock (this) { if (alreadyFired) { return; } if (Config.ResendOnTimeout && resendFunc(msg)) { if (logger.IsVerbose) { logger.Verbose("OnTimeout - Resend {0} for {1}", msg.ResendCount, msg); } return; } alreadyFired = true; DisposeTimer(); if (StatisticsCollector.CollectApplicationRequestsStats) { timeSinceIssued.Stop(); } if (unregister != null) { unregister(); } } string messageHistory = msg.GetTargetHistory(); string errorMsg = String.Format("Response did not arrive on time in {0} for message: {1}. Target History is: {2}", timeout, msg, messageHistory); logger.Warn(ErrorCode.Runtime_Error_100157, "{0}. About to break its promise.", errorMsg); var error = new Message(Message.Categories.Application, Message.Directions.Response) { Result = Message.ResponseTypes.Error, BodyObject = Response.ExceptionResponse(new TimeoutException(errorMsg)) }; if (StatisticsCollector.CollectApplicationRequestsStats) { ApplicationRequestsStatisticsGroup.OnAppRequestsEnd(timeSinceIssued.Elapsed); ApplicationRequestsStatisticsGroup.OnAppRequestsTimedOut(); } callback(error, context); }
public static Message CreatePromptExceptionResponse(Message request, Exception exception) { return(new Message { Category = request.Category, Direction = Message.Directions.Response, Result = Message.ResponseTypes.Error, BodyObject = Response.ExceptionResponse(exception) }); }
private void ResponseCallback(Message message, TaskCompletionSource <object> context) { Response response; if (message.Result != Message.ResponseTypes.Rejection) { try { response = (Response)message.GetDeserializedBody(this.serializationManager); } catch (Exception exc) { // catch the Deserialize exception and break the promise with it. response = Response.ExceptionResponse(exc); } } else { Exception rejection; switch (message.RejectionType) { case Message.RejectionTypes.GatewayTooBusy: rejection = new GatewayTooBusyException(); break; case Message.RejectionTypes.DuplicateRequest: return; // Ignore duplicates default: rejection = message.GetDeserializedBody(this.serializationManager) as Exception; if (rejection == null) { if (string.IsNullOrEmpty(message.RejectionInfo)) { message.RejectionInfo = "Unable to send request - no rejection info available"; } rejection = new OrleansMessageRejectionException(message.RejectionInfo); } break; } response = Response.ExceptionResponse(rejection); } if (!response.ExceptionFlag) { context.TrySetResult(response.Data); } else { context.TrySetException(response.Exception); } }
private void SafeSendResponse(Message message, object resultObject) { try { SendResponse(message, new Response(SerializationManager.DeepCopy(resultObject))); } catch (Exception exc) { logger.Warn(ErrorCode.IGC_SendResponseFailed, "Exception trying to send a response: " + exc.Message, exc); SendResponse(message, Response.ExceptionResponse(exc)); } }
private void SafeSendExceptionResponse(Message message, Exception ex) { try { SendResponse(message, Response.ExceptionResponse((Exception)SerializationManager.DeepCopy(ex))); } catch (Exception exc1) { try { logger.Warn(ErrorCode.IGC_SendExceptionResponseFailed, "Exception trying to send an exception response: " + exc1.Message, exc1); SendResponse(message, Response.ExceptionResponse(exc1)); } catch (Exception exc2) { logger.Warn(ErrorCode.IGC_UnhandledExceptionInInvoke, "Exception trying to send an exception. Ignoring and not trying to send again. Exc: " + exc2.Message, exc2); } } }