Skip to content

Commit

Permalink
added price initiator to keep price shards warm w/o entity passivation (
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored Aug 16, 2019
1 parent 4babf95 commit 98d6c8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Akka.CQRS.Pricing.Actors/MatchAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ private void Recovers()
/// Recovery has completed successfully.
/// </summary>
protected override void OnReplaySuccess()
{
_publishPricesTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(TimeSpan.FromSeconds(10),
TimeSpan.FromSeconds(10), Self, PublishEvents.Instance, ActorRefs.NoSender);
{

// setup subscription to TradeEventPublisher
Self.Tell(DoSubscribe.Instance);
Expand Down Expand Up @@ -263,6 +261,9 @@ private void Commands()

protected override void PreStart()
{
_publishPricesTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(TimeSpan.FromSeconds(10),
TimeSpan.FromSeconds(10), Self, PublishEvents.Instance, ActorRefs.NoSender);

_log.Info("Starting...");
base.PreStart();
}
Expand Down
4 changes: 4 additions & 0 deletions src/Akka.CQRS.Pricing.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ static int Main(string[] args)

var sharding = ClusterSharding.Get(actorSystem);


var shardRegion = sharding.Start("priceAggregator",
s => Props.Create(() => new MatchAggregator(s)),
ClusterShardingSettings.Create(actorSystem),
new StockShardMsgRouter());

var priceInitiatorActor = actorSystem.ActorOf(ClusterSingletonManager.Props(Props.Create(() => new PriceInitiatorActor(shardRegion)),
ClusterSingletonManagerSettings.Create(actorSystem).WithRole("pricing-engine").WithSingletonName("priceInitiator")), "priceInitiator");

var clientHandler =
actorSystem.ActorOf(Props.Create(() => new ClientHandlerActor(shardRegion)), "subscriptions");

Expand Down

0 comments on commit 98d6c8d

Please sign in to comment.