Exemple #1
0
        private void Ready()
        {
            Receive <AggregateCommandEnvelope>(envelope =>
            {
                var command = envelope.Command;
                var key     = command.Stream.Name + "|" + envelope.AggregateType.FullName;
                IActorRef aRef;

                // if the aggregate doesn't exist, create it
                if (!_aggregates.TryGetValue(key, out aRef))
                {
                    var props = PropsFactory.Create(envelope.AggregateType);
                    aRef      = Context.ActorOf(props);
                    aRef.Tell(new InitializeAggregate(_reader, _writer, _options));
                    _aggregates.Add(key, aRef);
                    Context.Watch(aRef);
                }

                aRef.Forward(command);
            });

            // remove children that are going to stop
            Receive <WillStop>(_ =>
            {
                if (RemoveActiveProcessor(Sender))
                {
                    Sender.Tell(StopNoticeAcknowledged.Instance);
                }
            });

            // remove terminated children
            Receive <Terminated>(t => RemoveActiveProcessor(t.ActorRef));
        }
 void Ready()
 {
     Receive <StartEventProcessor>(m =>
     {
         var props = PropsFactory.Create(m.EventProcessorType);
         Context.ActorOf(props);
     });
 }
Exemple #3
0
 void Ready()
 {
     Receive <StartProjection>(sp =>
     {
         try
         {
             var props      = PropsFactory.Create(sp.ProjectionType);
             var projection = Context.ActorOf(props);
             projection.Ask(new InitializeProjection(_projectionStreams, _options)).PipeTo(Sender);
         }
         catch (Exception ex)
         {
             Sender.Tell(InitializationResult.Failed(ex));
         }
     });
 }