Ejemplo n.º 1
0
        private async Task <byte[]> RequestResponseActorMessageAsync(
            IServiceRemotingRequestContext requestContext,
            ServiceRemotingMessageHeaders messageHeaders,
            byte[] requestBody,
            ActorMessageHeaders actorMessageHeaders,
            CustomServiceRequestHeader customHeader)
        {
            var methodName = GetActorMethodName(actorMessageHeaders);

            byte[] result = null;
            using (new ServiceRequestContextWrapper(customHeader))
            {
                using (_logger?.RecieveActorMessage(_actorService.Context.ServiceName, methodName, actorMessageHeaders, customHeader))
                {
                    try
                    {
                        result = await _innerMessageHandler.RequestResponseAsync(requestContext, messageHeaders, requestBody);
                    }
                    catch (Exception ex)
                    {
                        _logger?.RecieveActorMessageFailed(_actorService.Context.ServiceName, methodName, actorMessageHeaders, customHeader, ex);
                        throw;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        private string GetActorMethodName(ActorMessageHeaders actorMessageHeaders)
        {
            if (actorMessageHeaders == null)
            {
                return(null);
            }
            try
            {
                var methodName = "-";
                var lookup     = HashUtil.Combine(actorMessageHeaders.InterfaceId, actorMessageHeaders.MethodId);
                if (MethodMap.ContainsKey(lookup))
                {
                    methodName = MethodMap[lookup];
                    return(methodName);
                }

                methodName = ((Microsoft.ServiceFabric.Actors.Remoting.Runtime.ActorServiceRemotingDispatcher) this).GetMethodDispatcherMapName(
                    actorMessageHeaders.InterfaceId, actorMessageHeaders.MethodId);
                MethodMap[lookup] = methodName;
                return(methodName);
            }
            catch (Exception ex)
            {
                // ignored
                CommunicationLogger?.FailedToGetActorMethodName(actorMessageHeaders, ex);
            }
            return(null);
        }
Ejemplo n.º 3
0
 public static bool TryFromServiceMessageHeaders(ServiceRemotingMessageHeaders headers, out ActorMessageHeaders actorHeaders)
 {
     actorHeaders = (ActorMessageHeaders)null;
     byte[] headerValue;
     if (!headers.TryGetHeaderValue(ActorMessageHeaderName, out headerValue))
     {
         return(false);
     }
     actorHeaders = ActorMessageHeaders.Deserialize(headerValue);
     return(true);
 }
Ejemplo n.º 4
0
 internal static ActorMessageHeaders GetActorMessageHeaders(this ServiceRemotingMessageHeaders messageHeaders, IActorServiceCommunicationLogger logger)
 {
     try
     {
         ActorMessageHeaders actorMessageHeaders;
         if (ActorMessageHeaders.TryFromServiceMessageHeaders(messageHeaders, out actorMessageHeaders))
         {
             return(actorMessageHeaders);
         }
     }
     catch (Exception ex)
     {
         // ignored
         logger?.FailedToReadActorMessageHeaders(messageHeaders, ex);
     }
     return(null);
 }