{"id":15421030,"url":"https://github.com/cjsheets/azure-queue-consumer","last_synced_at":"2025-09-19T20:12:28.694Z","repository":{"id":143840134,"uuid":"131453358","full_name":"cjsheets/azure-queue-consumer","owner":"cjsheets","description":null,"archived":false,"fork":false,"pushed_at":"2018-04-29T02:24:26.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T00:38:12.196Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cjsheets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-29T00:12:33.000Z","updated_at":"2018-04-29T02:24:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"128e09db-1e9a-4b52-ba6c-af41dd275f47","html_url":"https://github.com/cjsheets/azure-queue-consumer","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"4f64d0beb9c838c6029321db25bb60f66b5d8307"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjsheets%2Fazure-queue-consumer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjsheets%2Fazure-queue-consumer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjsheets%2Fazure-queue-consumer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjsheets%2Fazure-queue-consumer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjsheets","download_url":"https://codeload.github.com/cjsheets/azure-queue-consumer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239471287,"owners_count":19644288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T17:32:45.376Z","updated_at":"2025-09-19T20:12:23.639Z","avatar_url":"https://github.com/cjsheets.png","language":"JavaScript","readme":"# azure-queue-consumer\n\n[![Build Status](https://travis-ci.org/cjsheets/azure-queue-consumer.svg)](https://travis-ci.org/cjsheets/azure-queue-consumer)\n\nBuild Azure data queue-based applications without the boilerplate. Just define a function that receives an Azure data queue message and call a callback when the message has been processed.\n\n## Installation\n\n```bash\nnpm install azure-queue-consumer --save\n```\n\n## Usage\n\n```js\nconst Consumer = require('azure-queue-consumer');\n\nconst app = Consumer.create({\n  queueUrl: 'https://account-name.queue.core.windows.net/queue-name',\n  handleMessage: (message, done) =\u003e {\n    // do some work with `message`\n    done();\n  }\n});\n\napp.on('error', (err) =\u003e {\n  console.log(err.message);\n});\n\napp.start();\n```\n\n* The queue is polled every second by default.\n* Messages are deleted from the queue once `done()` is called.\n* Messages are processed one at a time.\n\n### Credentials\n\nBy default the consumer will look for Azure credentials in the places [specified by the Azure Storage SDK](http://azure.github.io/azure-storage-node/#toc4). The simplest option is to export your credentials as environment variables:\n\n```bash\nexport AZURE_STORAGE_CONNECTION_STRING=...\n```\n\nIf you need to specify your credentials manually, you can use a pre-configured instance of the [Azure QueueService](http://azure.github.io/azure-storage-node/#toc7__anchor):\n\n\n```js\nconst Consumer = require('azure-queue-consumer');\nconst azureStorage = require('azure-storage');\n\nconst app = Consumer.create({\n  queueUrl: 'https://account-name.queue.core.windows.net/queue-name',\n  handleMessage: (message, done) =\u003e {\n    // ...\n    done();\n  },\n  queueService: azureStorage.createQueueServiceWithSas(\n    'https://account-name.queue.core.windows.net/queue-name',\n    '\u003cSAS Token\u003e'\n  );\n});\n\napp.on('error', (err) =\u003e {\n  console.log(err.message);\n});\n\napp.start();\n```\n\n## API\n\n### `Consumer.create(options)`\n\nCreates a new Azure data queue consumer.\n\n#### Options\n\n* `queueUrl` - _String_ - The Azure data queue URL\n* `handleMessage` - _Function_ - A function to be called whenever a message is received. Receives a queue message object as its first argument and a function to call when the message has been handled as its second argument (i.e. `handleMessage(message, done)`).\n* `pollDelaySeconds` - _Number_ - The delay (in seconds) between queue polling attempts while the queue is empty.\n* `waitTimeSeconds` - _Number_ - maximum execution time across all potential retries, for requests made via the Queue service.\n* `authenticationErrorTimeout` - _Number_ - The duration (in milliseconds) to wait before retrying after an authentication error (defaults to `10000`).\n* `queueService` - _Object_ - An optional [Azure QueueService](http://azure.github.io/azure-storage-node/#toc7__anchor) instance to use if you need to configure the client manually\n\n### `consumer.start()`\n\nStart polling the queue for messages.\n\n### `consumer.stop()`\n\nStop polling the queue for messages.\n\n### Events\n\nEach consumer is an [`EventEmitter`](http://nodejs.org/api/events.html) and emits the following events:\n\n|Event|Params|Description|\n|-----|------|-----------|\n|`error`|`err`, `[message]`|Fired when an error occurs interacting with the queue. If the error correlates to a message, that error is included in Params|\n|`processing_error`|`err`, `message`|Fired when an error occurs processing the message.|\n|`message_received`|`message`|Fired when a message is received.|\n|`message_processed`|`message`|Fired when a message is successfully processed and removed from the queue.|\n|`response_processed`|None|Fired after one batch of items (up to `batchSize`) has been successfully processed.|\n|`stopped`|None|Fired when the consumer finally stops its work.|\n|`empty`|None|Fired when the queue is empty (All messages have been consumed).|\n\n\n### Credits\n\nInspired by [SQS Consumer](https://github.com/bbc/sqs-consumer)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjsheets%2Fazure-queue-consumer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjsheets%2Fazure-queue-consumer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjsheets%2Fazure-queue-consumer/lists"}