public async Task Handle(T message, IMessageHandlerContext context)
        {
            var messageType = message.GetType().Name;

            logger.LogInfo($"Processing {messageType} event. Ukprn: {message.Ukprn}");
            ((ESFA.DC.Logging.ExecutionContext)executionContext).JobId = message.JobId.ToString();

            if (message.Ukprn == 0)
            {
                throw new ArgumentException($"Ukprn cannot be 0. Job Id: {message.JobId}");
            }

            logger.LogDebug($"Getting AccountId for Ukprn: {message.Ukprn}.");
            var accountIds = await repository.GetEmployerAccountsByUkprn(message.Ukprn).ConfigureAwait(false);

            var tasks = new List <Task>();

            foreach (var account in accountIds)
            {
                var accountToUse = levyMessageRoutingService.GetDestinationAccountId(account.Item1, account.Item2);
                tasks.Add(InvokeSubmissionAction(accountToUse, message));
            }

            await Task.WhenAll(tasks).ConfigureAwait(false);

            logger.LogInfo($"Successfully processed {messageType} for Job: {message.JobId}, UKPRN: {message.Ukprn}. Skipped submission removing as no account ID found.");
        }
Пример #2
0
        public async Task Handle(CalculatedRequiredLevyAmount message, IMessageHandlerContext context)
        {
            paymentLogger.LogInfo($"Processing ApprenticeshipContractType1RequiredPaymentEvent event. Message Id: {context.MessageId}, Job: {message.JobId}, UKPRN: {message.Ukprn}");
            executionContext.JobId = message.JobId.ToString();

            if (!message.AccountId.HasValue)
            {
                throw new ArgumentException($"Employer AccountId cannot be null. Event id:  {message.EventId}");
            }

            var accountToUse = levyMessageRoutingService.GetDestinationAccountId(message);

            paymentLogger.LogDebug($"Sending levy message to levy actor: {accountToUse}.  Account: {message.AccountId}, sender: {message.TransferSenderAccountId}. ");
            var actorId = new ActorId(accountToUse);
            var actor   = proxyFactory.CreateActorProxy <ILevyFundedService>(new Uri("fabric:/SFA.DAS.Payments.FundingSource.ServiceFabric/LevyFundedServiceActorService"), actorId);
            await actor.HandleRequiredPayment(message).ConfigureAwait(false);

            paymentLogger.LogInfo($"Successfully processed LevyFundedProxyService event for Actor Id {actorId}, Job: {message.JobId}, UKPRN: {message.Ukprn}");
        }