private async Task UpdateQueueStatusInCache(QueueStatusDto queueStatus, string cacheKey)
        {
            var serialoizedObject = JsonConvert.SerializeObject(queueStatus);
            var objectBytes       = Encoding.UTF8.GetBytes(serialoizedObject);

            await _cache.SetAsync(cacheKey, objectBytes, new DistributedCacheEntryOptions());
        }
Пример #2
0
        public QueueStatusDto GetQueueStatus(RabbitMQConnectionConfig connectionConfig, RabbitMQQueueConfig queue, RabbitMQExchangeConfig exchange, string routingKey)
        {
            this.ValidateRules(connectionConfig, queue, exchange);

            QueueStatusDto result;

            ConnectionFactory factory = this.CreateConnectionFactory(connectionConfig);

            using (IConnection connection = factory.CreateConnection())
                using (IModel channel = connection.CreateModel())
                {
                    QueueDeclareOk queueDeclare = channel.QueueDeclarePassive(queue.Name);
                    result = new QueueStatusDto(queueDeclare.QueueName, (int)queueDeclare.MessageCount, (int)queueDeclare.ConsumerCount);
                }

            return(result);
        }
        private async Task <QueueStatusDto> AddQueueStatusToCache(string projectId, string branchName, string cacheKey)
        {
            var queueStatus = new QueueStatusDto
            {
                ProjectId  = projectId,
                BranchName = branchName,
                StartTime  = DateTime.UtcNow,
                NumberOfIndexedDocuments = 0,
                NumberOfAllDocuments     = null,
                IndexStatus = IndexStatusEnum.Indexing
            };
            var serialoizedObject = JsonConvert.SerializeObject(queueStatus);
            var objectBytes       = Encoding.UTF8.GetBytes(serialoizedObject);

            await _cache.SetAsync(cacheKey, objectBytes, new DistributedCacheEntryOptions());

            return(queueStatus);
        }
Пример #4
0
        public IActionResult GetStatus()
        {
            QueueStatusDto result = this.CustomerService.GetQueueStatus();

            return(Ok(new ResponseDto <QueueStatusDto>(true, result)));
        }