示例#1
0
 /// <summary>
 /// Returns Props for the IMessageProcessActor based on the current configuration.
 /// </summary>
 /// <returns>Props for the IMessageProcessActor based on the current configuration</returns>
 public Props CreateMessageProcessActorProps()
 {
     // DO NOT use a Pool of Actors as we have a certain state in this actor which should be kept between the calls.
     return(_gatewayConfiguration.HasInterval()
         ? Props.Create(() => new DelayMessageProcessActor(_actorSystem, _gatewayConfiguration))
         : Props.Create(() => new InstantMessageProcessActor(_actorSystem, _gatewayConfiguration)));
 }
示例#2
0
        /// <summary>
        /// Magic method that is called by dependency injection on startup.
        /// Initializes the Actors so they'll start working
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _actorSystem
            .ActorOf(_actorPropsFactory.CreatePublishActorProps(), PublishActorName);
            var messageProcessActor = _actorSystem
                                      .ActorOf(_actorPropsFactory.CreateMessageProcessActorProps(), MessageProcessActorName);
            var ognActor = _actorSystem
                           .ActorOf(_actorPropsFactory.CreateOgnConvertActorProps(), OgnConvertActorName);

            _stream = _streamProvider.Stream.Subscribe(message => ognActor.Tell(message));

            if (_gatewayConfiguration.HasInterval())
            {
                _actorSystem.Scheduler.ScheduleTellRepeatedly(
                    TimeSpan.Zero,
                    TimeSpan.FromSeconds(_gatewayConfiguration.GetIntervalSeconds()),
                    messageProcessActor,
                    new DelayMessageProcessActor.PushMessages(),
                    null
                    );
            }

            return(Task.CompletedTask);
        }