private Task AccountChanged(IMarginTradingAccount account, AccountEventTypeEnum eventType) { var message = new AccountChangedMessage { Account = account.ToFullBackendContract(_settings.IsLive), EventType = eventType, }; return(TryProduceMessageAsync(_settings.RabbitMqQueues.AccountChanged.ExchangeName, message)); }
public async Task ProcessAccountChanged(AccountChangedMessage accountChangedMessage) { if (accountChangedMessage.EventType != AccountEventTypeEnum.Updated) { return; } var account = accountChangedMessage.Account; var queueName = QueueHelper.BuildQueueName(_settings.MarginTradingFront.RabbitMqQueues.AccountChanged.ExchangeName, _settings.MarginTradingFront.Env); _consoleWriter.WriteLine($"Get account change from {queueName} queue for clientId = {account.ClientId}"); var notificationId = await _clientNotificationService.GetNotificationId(account.ClientId); var userTopic = _realm.Services.GetSubject <NotifyResponse <MarginTradingAccountClientContract> >($"user.{notificationId}"); var notifyResponse = new NotifyResponse <MarginTradingAccountClientContract> { Entity = account.ToClientContract(), Type = NotifyEntityType.Account }; userTopic.OnNext(notifyResponse); _operationsLog.AddLog($"topic user.{notificationId} (account changed)", account.ClientId, account.Id, null, notifyResponse.ToJson()); _consoleWriter.WriteLine($"topic user.{notificationId} (account changed) for clientId = {account.ClientId}"); var userUpdateTopic = _realm.Services.GetSubject <NotifyResponse>($"user.updates.{notificationId}"); var userUpdateTopicResponse = new NotifyResponse { Account = notifyResponse.Entity, Order = null }; userUpdateTopic.OnNext(userUpdateTopicResponse); _operationsLog.AddLog($"topic user.updates.{notificationId} (account changed)", account.ClientId, account.Id, null, userUpdateTopicResponse.ToJson()); _consoleWriter.WriteLine($"topic user.updates.{notificationId} (account changed) for clientId = {account.ClientId}"); }
private void OnAccountChanged(AccountChangedMessage msg) { // TODO: Rebuild bound data }