Exemplo n.º 1
0
        protected virtual void AwaitingCommandBehavior()
        {
            Command <AggregateActor.ExecuteCommand>(m =>
            {
                var cmd = m.Command;
                Log.Debug("Received command {cmdId}", cmd.Id);

                ExecutionContext.Command         = cmd;
                ExecutionContext.CommandMetadata = m.Metadata;
                ExecutionContext.CommandSender   = Sender;

                try
                {
                    Aggregate.Execute(ExecutionContext.Command)
                    .PipeTo(Self);
                }
                catch (Exception ex)
                {
                    StopOnException(ex);
                }


                Behavior.Become(ProcessingCommandBehavior, nameof(ProcessingCommandBehavior));
            });
        }
Exemplo n.º 2
0
        public AggregateActor()
        {
            Behavior = new BehaviorQueue(Become);
            Behavior.Become(AwaitingCommandBehavior, nameof(AwaitingCommandBehavior));
            PersistenceId = Self.Path.Name;
            Id            = EntityActorName.Parse <TAggregate>(Self.Path.Name).Id;

            var aggregateExtensions = Context.System.GetAggregatesExtension();
            var dependencies        = aggregateExtensions.GetDependencies <TAggregate>();

            Aggregate = dependencies.AggregateFactory.Build();


            Recover <DomainEvent>(e => Aggregate.Apply(e));
        }
Exemplo n.º 3
0
        public ProcessActor(IProcess <TState> process, IProcessStateFactory <TState> processStateFactory)

        {
            Process  = process;
            Monitor  = new ActorMonitor(Context, "Process" + typeof(TState).Name);
            Behavior = new BehaviorQueue(Become);

            if (!EntityActorName.TryParseId(Self.Path.Name, out var id))
            {
                throw new BadNameFormatException();
            }

            Id = id;

            _publisher           = Context.System.GetTransport();
            _processStateFactory = processStateFactory;
            _log = Context.GetSeriLogger();

            _exceptionOnTransit  = ProcessManagerActorConstants.ExceptionOnTransit(Self.Path.Name);
            _producedCommand     = ProcessManagerActorConstants.ProcessProduceCommands(Self.Path.Name);
            _stateActorSelection = Context.System.ActorSelection(ProcessStateActorSelection);

            Behavior.Become(InitializingBehavior, nameof(InitializingBehavior));
        }