CreateQueue(
            CreateQueueCommandModel createQueueModel)
        {
            if (createQueueModel == null)
                throw new ArgumentNullException(nameof(createQueueModel));

            if (!this.ModelState.IsValid)
                return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, this.ModelState);

            var monitor = new SlinqyQueueShardMonitor(
                createQueueModel.QueueName,
                PhysicalQueueService
            );

            slinqyAgent = new SlinqyAgent(
                PhysicalQueueService,
                monitor,
                createQueueModel.StorageCapacityScaleOutThresholdPercentage / 100D,
                4
            );

            await slinqyAgent.Start();

            SlinqyQueues.Add(
                createQueueModel.QueueName,
                new SlinqyQueue(monitor)
            );

            var response = new HttpResponseMessage(HttpStatusCode.Created) {
                Content = new ObjectContent<QueueInformationViewModel>(
                    new QueueInformationViewModel(
                        queueName:              createQueueModel.QueueName,
                        maxQueueSizeMegabytes:  createQueueModel.MaxQueueSizeMegabytes,
                        currentQueueSizeBytes:  0
                    ),
                    new JsonMediaTypeFormatter()
                )
            };

            return response;
        }
Beispiel #2
0
        CreateQueue(
            CreateQueueCommandModel createQueueModel)
        {
            if (createQueueModel == null)
                throw new ArgumentNullException(nameof(createQueueModel));

            var queue = await SlinqyQueueClient.CreateQueueAsync(
                queueName:          createQueueModel.QueueName,
                shardIndexPadding:  4
            );

            var monitor = new SlinqyQueueShardMonitor(
                createQueueModel.QueueName,
                PhysicalQueueService
            );

            slinqyAgent = new SlinqyAgent(
                PhysicalQueueService,
                monitor,
                createQueueModel.StorageCapacityScaleOutThresholdPercentage / 100D
            );

            await slinqyAgent.Start();

            return new QueueInformationViewModel(
                queue.Name,
                queue.MaxQueueSizeMegabytes,
                queue.CurrentQueueSizeBytes
            );
        }