public void NotifyOrderChanged(Order order) { _rabbitMqNotifyService.OrderChanged(order); var queueName = QueueHelper.BuildQueueName(_marginSettings.RabbitMqQueues.OrderChanged.ExchangeName, _marginSettings.Env); _consoleWriter.WriteLine($"send order changed to queue {queueName}"); _operationsLogService.AddLog($"queue {queueName}", order.ClientId, order.AccountId, null, order.ToJson()); }
public void NotifyAccountStopout(string clientId, string accountId, int positionsCount, decimal totalPnl) { _rabbitMqNotifyService.AccountStopout(clientId, accountId, positionsCount, totalPnl); var queueName = QueueHelper.BuildQueueName(_marginSettings.RabbitMqQueues.AccountStopout.ExchangeName, _marginSettings.Env); _consoleWriter.WriteLine($"send account stopout to queue {queueName}"); _operationsLogService.AddLog($"queue {queueName}", clientId, accountId, null, new { clientId = clientId, accountId = accountId, positionsCount = positionsCount, totalPnl = totalPnl }.ToJson()); }
private RabbitMqSubscriptionSettings GetRabbitMqSubscriptionSettings() { return(new RabbitMqSubscriptionSettings { ConnectionString = Settings.MtRabbitMqConnString, QueueName = QueueHelper.BuildQueueName(ExchangeName, Settings.Env, QueuePostfix), ExchangeName = ExchangeName, IsDurable = true }); }
public async Task NotifyTradingConditionsChanged(string tradingConditionId = null, string accountId = null) { if (!string.IsNullOrEmpty(tradingConditionId)) { var clientIds = _accountsCacheService .GetClientIdsByTradingConditionId(tradingConditionId, accountId).ToArray(); if (clientIds.Length > 0) { await _rabbitMqNotifyService.UserUpdates(true, false, clientIds); _consoleWriter.WriteLine( $"send user updates to queue {QueueHelper.BuildQueueName(_marginSettings.RabbitMqQueues.UserUpdates.ExchangeName, _marginSettings.Env)}"); } } }
public RabbitMqSubscriptionSettings GetRabbitMqSubscriptionSettings() { var settings = new RabbitMqSubscriptionSettings { ConnectionString = Settings.MtRabbitMqConnString, QueueName = QueueHelper.BuildQueueName(ExchangeName, Settings.Env, QueuePostfix), ExchangeName = ExchangeName, IsDurable = true, DeadLetterExchangeName = QueueHelper.BuildDeadLetterExchangeName(ExchangeName), }; if (!string.IsNullOrWhiteSpace(RoutingKey)) { settings.RoutingKey = RoutingKey; } return(settings); }
public void Start() { var settings = new RabbitMqSubscriptionSettings() { ConnectionString = _settings.MtRabbitMqConnString, ExchangeName = _settings.RabbitMqQueues.OrderbookPrices.ExchangeName, QueueName = QueueHelper.BuildQueueName(_settings.RabbitMqQueues.OrderbookPrices.ExchangeName, nameof(PricesCacheService)), IsDurable = false }; _subscriber = new RabbitMqSubscriber <InstrumentBidAskPairContract>(settings, new DefaultErrorHandlingStrategy(_log, settings)) .SetMessageDeserializer(new FrontEndDeserializer <InstrumentBidAskPairContract>()) .SetMessageReadStrategy(new MessageReadWithTemporaryQueueStrategy()) .SetLogger(_log) .Subscribe(ProcessPrice) .Start(); }
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}"); }