protected virtual IActorRef FindOrCreate(AggregateMessage message) { var idToken = message switch { BankAccountMessage _ => "bank", UserMessage _ => "user", _ => null }; var aggregateId = $"{idToken}-{message.Id}"; var aggregate = Context.Child(aggregateId); if (aggregate.IsNobody()) { Props props = message switch { BankAccountMessage _ => Props.Create(() => new BankAccount()), UserMessage _ => Props.Create(() => new User()), _ => null }; aggregate = CreateAggregate(props, aggregateId); } return(aggregate); }
public bool Forward(AggregateMessage message) { _logger.Info("Received message of Type={0}", message.GetType()); var aggregate = FindOrCreate(message); aggregate.Forward(message); return(true); }