Skip to content

Commit

Permalink
[CON-2942] Small refactor and additional log
Browse files Browse the repository at this point in the history
  • Loading branch information
cofaulco committed Jan 7, 2021
1 parent c6b9909 commit fd26830
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ public async Task Run(

var now = _currentDateTime.Now;
var accounts = await _accountRepository.GetAllAccounts();
var commands = accounts.Select(a => new ExpireAccountFundsCommand { AccountId = a.Id });

var tasks = commands.Select(c =>
logger.LogInformation($"Queueing {nameof(ExpireAccountFundsCommand)} messages for {accounts.Count} accounts.");

var tasks = accounts.Select(a =>
{
var sendOptions = new SendOptions();

sendOptions.RequireImmediateDispatch();
sendOptions.SetMessageId($"{nameof(ExpireAccountFundsCommand)}-{now.Year}-{now.Month}-{c.AccountId}");
sendOptions.SetMessageId($"{nameof(ExpireAccountFundsCommand)}-{now.Year}-{now.Month}-{a.Id}");

return _messageSession.Send(c, sendOptions);
return _messageSession.Send(new ExpireAccountFundsCommand { AccountId = a.Id }, sendOptions);
});

await Task.WhenAll(tasks);
Expand Down

0 comments on commit fd26830

Please sign in to comment.