/// <summary>
        /// Main method to chain an order take in an executable order
        /// Allow actors to directly make call to next actor via an executable order object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="nextActorRequestContext"></param>
        /// <param name="payload"></param>
        /// <param name="excutableOrder"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        protected virtual async Task ChainNextActorsAsync(ActorRequestContext nextActorRequestContext, object payload, Type typeOfPayload, ExecutableOrchestrationOrder excutableOrder, CancellationToken cancellationToken)
        {
            //try to complete the step
            await CompleteStepAsync(payload);

            try
            {
                await ActorClient.ChainNextActorAsync(nextActorRequestContext, payload, typeOfPayload, new ActorIdentity(excutableOrder.ActorId, excutableOrder.ActorServiceUri), cancellationToken);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, $"{CurrentActor} failed to chain next actor {excutableOrder?.ActorServiceUri} with actor id {excutableOrder?.ActorId}. Message: {ex.Message}");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method will allow supports for Flow&Step involed in the implementation without a strong type expression of the interface
        /// This method also help when we have methodName resolved by a serialized Step
        /// </summary>
        /// <param name="methodName"></param>
        /// <param name="actorRequestContext"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        private static async Task Invoke(string methodName, ActorRequestContext actorRequestContext, params object[] arguments)
        {
            if (actorRequestContext?.TargetActor == null)
            {
                throw new ArgumentNullException(INVALID_TARGET_ACTOR_ERROR_MESSAGE);
            }

            var serializableMethodInfo = new SerializableMethodInfo();

            serializableMethodInfo.MethodName = methodName;
            actorRequestContext.MethodName    = methodName;

            foreach (var arg in arguments)
            {
                serializableMethodInfo.Arguments.Add(new SerializableMethodArgument()
                {
                    ArgumentAssemblyType = arg.GetType().AssemblyQualifiedName,
                    Value = _binaryMessageSerializer.SerializePayload(arg)
                });
            }
            actorRequestContext.ActionName = actorRequestContext.ActionName;
            await _actorClient.ChainNextActorAsync <SerializableMethodInfo>(actorRequestContext, serializableMethodInfo, actorRequestContext.TargetActor, CancellationToken.None);
        }