示例#1
0
        private static void OnRejection(Message message, IResponseCompletionSource context)
        {
            Exception rejection;

            switch (message.RejectionType)
            {
            case Message.RejectionTypes.GatewayTooBusy:
                rejection = new GatewayTooBusyException();
                break;

            case Message.RejectionTypes.DuplicateRequest:
                return;     // Ignore duplicates

            default:
                rejection = message.BodyObject 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;
            }

            context.Complete(Response.FromException(rejection));
        }
示例#2
0
 public static Message CreatePromptExceptionResponse(Message request, Exception exception)
 {
     return(new Message
     {
         Category = request.Category,
         Direction = Message.Directions.Response,
         Result = Message.ResponseTypes.Error,
         BodyObject = Response.FromException(exception)
     });
 }
示例#3
0
 public static void ResponseCallback(Message message, IResponseCompletionSource context)
 {
     if (message.Result != Message.ResponseTypes.Rejection)
     {
         try
         {
             var response = (Response)message.BodyObject;
             context.Complete(response);
         }
         catch (Exception exc)
         {
             // catch the exception and break the promise with it.
             context.Complete(Response.FromException(exc));
         }
     }
     else
     {
         OnRejection(message, context);
     }
 }