diff --git a/lib/actions/queue/GetQueueMetadata.js b/lib/actions/queue/GetQueueMetadata.js index db5b015..318eb6e 100644 --- a/lib/actions/queue/GetQueueMetadata.js +++ b/lib/actions/queue/GetQueueMetadata.js @@ -10,11 +10,13 @@ class GetQueueMetadata { process(request, res) { const queue = QueueManager.getQueueAndMessage({ queueName: request.queueName }).queue, metaProps = queue.metaProps, + queueLength = queue.getLength(), response = new AzuriteQueueResponse(); response.addMetaProps(metaProps); + response.addHttpProperty(`x-ms-approximate-messages-count`, queueLength); res.set(response.httpProps); res.status(200).send(); } } -module.exports = new GetQueueMetadata(); \ No newline at end of file +module.exports = new GetQueueMetadata(); diff --git a/lib/model/queue/AzuriteQueueResponse.js b/lib/model/queue/AzuriteQueueResponse.js index 5bdaacf..6b5b828 100644 --- a/lib/model/queue/AzuriteQueueResponse.js +++ b/lib/model/queue/AzuriteQueueResponse.js @@ -24,4 +24,4 @@ class AzuriteQueueResponse { } } -module.exports = AzuriteQueueResponse; \ No newline at end of file +module.exports = AzuriteQueueResponse; diff --git a/lib/model/queue/Queue.js b/lib/model/queue/Queue.js index 104b233..4e12ace 100644 --- a/lib/model/queue/Queue.js +++ b/lib/model/queue/Queue.js @@ -122,6 +122,10 @@ class Queue { index: index }; } + + getLength() { + return this.messages.length; + } } -module.exports = Queue; \ No newline at end of file +module.exports = Queue;