Beispiel #1
0
        private void Initializing()
        {
            Logger.Debug("Inventory Actor Initializing ....");
            Self.Tell(new InitializeInventoriesFromStorageMessage());
            ReceiveAsync <InitializeInventoriesFromStorageMessage>(async message =>
            {
                var inventoryIdsResult = await InventoryStorage.ReadAllInventoryIdAsync();

                if (inventoryIdsResult.IsSuccessful)
                {
                    Become(Processing);
                    foreach (var s in inventoryIdsResult.Result)
                    {
                        Logger.Debug("Initializing asking " + s + " for its inventory ....");
                        var invActorRef = GetActorRef(InventoryStorage, s, PerformanceService);
                        invActorRef.Tell(new GetInventoryMessage(s));
                    }
                }
                else
                {
                    var errorMsg = "Failed to read inventories from storage " + InventoryStorage.GetType().FullName + " - " + inventoryIdsResult.Errors.Flatten().Message;
                    Logger.Error("Inventory Actor Initialization Failed " + errorMsg);
                    throw new Exception(errorMsg, inventoryIdsResult.Errors.Flatten());
                }
            });
        }