Exemplo n.º 1
0
        /// <inheritdoc/>
        public IReadOnlyDictionary <string, uint> GetMessagesCount(bool withPoison = false)
        {
            var result = new Dictionary <string, uint>();

            foreach (var queueName in _queueNames)
            {
                var messageCount = RabbitMqService.GetMessageCount(_connectionString, queueName);
                result.Add(queueName, messageCount);

                if (withPoison)
                {
                    var poisonQueueName    = $"{queueName}{PoisonPostfix}";
                    var poisonMessageCount = RabbitMqService.GetMessageCount(_connectionString, poisonQueueName);
                    result.Add(poisonQueueName, poisonMessageCount);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check that RabbitMQ queues of other services which data is required for initialization are empty.
        /// </summary>
        public void Check()
        {
            foreach (var queueName in new[]
            {
                _marginTradingSettings.StartupQueuesChecker.OrderHistoryQueueName,
                _marginTradingSettings.StartupQueuesChecker.PositionHistoryQueueName
            })
            {
                var messageCount = RabbitMqService.GetMessageCount(
                    _marginTradingSettings.StartupQueuesChecker.ConnectionString,
                    queueName);
                if (messageCount == 0)
                {
                    continue;
                }

                throw new Exception(
                          $"All Order/Position broker queues from StartupQueuesChecker setting must be empty. Currently [{queueName}] contains [{messageCount}] messages.");
            }
        }