Esempio n. 1
0
        public Task StartAsync(IAsyncBusBroker busBroker)
        {
            _log.LogInformation($"Start Troll actor '{FactoryInstanceId}' of factory '{FactoryId}'");

            _bus = _busConfigFunc(busBroker);
            return(Task.FromResult(0));
        }
Esempio n. 2
0
        public Task StartAsync(IAsyncBusBroker busBroker)
        {
            var busEntity = _busEntityFunc(busBroker);

            _isInitialized = 1;

            return(Task.FromResult(0));
        }
Esempio n. 3
0
        public async Task StartAsync(IAsyncBusBroker busBroker)
        {
            _log.LogInformation($"Start Librarian actor instance #{FactoryInstanceId} of factory '{FactoryId}'");
            if (Interlocked.CompareExchange(ref _isInitialized, 1, 0) != 0)
            {
                _log.LogInformation($"Librarian actor #{FactoryInstanceId} of factory '{FactoryId}' already started");
                return;
            }

            _log.LogInformation($"Get async bus entity for Librarian actor #{FactoryInstanceId} of factory '{FactoryId}'");
            var busEntity = _busEntityFunc(busBroker);

            _log.LogInformation($"Subscribe for notifications from async bus entity '{busEntity.EntityId}', Librarian actor #{FactoryInstanceId} of factory '{FactoryId}'");
            await busEntity.SubscribeAsync <VersionCumulativeUpdateNotification <T> >(HandleMessageAsync);

            _log.LogInformation($"Librarian actor instance #{FactoryInstanceId} of factory '{FactoryId}' has been successfully started");
        }
Esempio n. 4
0
        private async Task Setup()
        {
            var rootOperationScopeProvider = new OperationScopeProvider();

            //_busBroker = new InProcAsyncBusBroker(LoggerFactory.CreateLogger("QX.Zoo.InProcAsyncBus"), rootOperationScopeProvider);
            _busBroker = new RabbitMQBroker(Configuration.GetValue <RabbitMQConfiguration>("rabbitmq"), rootOperationScopeProvider, LoggerFactory.CreateLogger("QX.Zoo.InProcAsyncBus"));

            var factoryId        = SequentialGuidGenerator.GetOrCreateGenerator <Citizen>().NewGuid();
            var maxVersionNumber = StaticCitizensWarehouse.Version;
            var warehouse        = new WarehouseActor <Citizen>(StaticCitizensWarehouse.ExternalLoader, LoggerFactory.CreateLogger("QX.Zoo.Warehouse"));

            _instance1 = new AccumulatingFactory <Citizen>(factoryId, 1, maxVersionNumber, b => b.GetEntity("exchange/zoo"), x => LoggerFactory.CreateLogger(x?.ToString()));
            _instance2 = new AccumulatingFactory <Citizen>(factoryId, 2, maxVersionNumber, b => b.GetEntity("exchange/zoo"), x => LoggerFactory.CreateLogger(x?.ToString()));
            _instance3 = new AccumulatingFactory <Citizen>(factoryId, 3, maxVersionNumber, b => b.GetEntity("exchange/zoo"), x => LoggerFactory.CreateLogger(x?.ToString()));

            await _instance1.StartAsync(_busBroker);

            await _instance2.StartAsync(_busBroker);

            await _instance3.StartAsync(_busBroker);
        }
Esempio n. 5
0
        public async Task StartAsync(IAsyncBusBroker busBroker)
        {
            _log.LogInformation((int)Events.Start, $"Start Vendor actor instance #{FactoryInstanceId} of factory '{FactoryId}'");
            if (Interlocked.CompareExchange(ref _isInitialized, 1, 0) != 0)
            {
                _log.LogWarning($"Vendor actor #{FactoryInstanceId} of factory '{FactoryId}' already started");
                return;
            }

            _log.LogVerbose($"Start internal Vendor actor instance #{_librarian.FactoryInstanceId} of factory '{FactoryId}'");
            await _librarian.StartAsync(busBroker);

            _log.LogVerbose($"Get async bus entity for Vendor actor #{FactoryInstanceId} of factory '{FactoryId}'");
            _busEntity = _busEntityFunc(busBroker);

            _log.LogVerbose($"Subscribe for notifications from async bus entity '{_busEntity.EntityId}', Vendor actor #{FactoryInstanceId} of factory '{FactoryId}'");
            await Task.WhenAll(
                _busEntity.SubscribeAsync <VersionConfirmNotification>(HandleMessageAsync),
                _busEntity.SubscribeAsync <VersionMoveAndConfirmNotification>(HandleMessageAsync));

            _log.LogInformation($"Vendor actor instance #{FactoryInstanceId} of factory '{FactoryId}' has been successfully started");
        }
Esempio n. 6
0
 public Task StartAsync(IAsyncBusBroker busBroker)
 {
     _log.LogInformation($"Starting accumulating factory #{FactoryInstanceId}/{FactoryId}");
     return(Task.WhenAll(_vendorActor.StartAsync(busBroker), _librarianNode.StartAsync(busBroker), _trollActor.StartAsync(busBroker)));
 }
Esempio n. 7
0
        public AsyncBusListenersFactory(IAsyncBusBroker asyncBusBroker, string actionsEntityId, ILogger log)
        {
            var entity = asyncBusBroker.GetEntity(actionsEntityId);

            ActionsListener = new ServiceInstanceListener(ctx => new AsyncBusListener(entity, ctx, log), entity.EntityId);
        }