Registry / devops / azure-abstract-queue-adapter

azure-abstract-queue-adapter

JSON →
library1.3.1jsnpmunverified

A unified abstraction layer for Azure Storage Queue and Azure Service Bus Message queues, allowing developers to switch between queue providers with a single line change. Version 1.3.1 provides a consistent API for create, list, delete queues, and send/receive messages as JSON or plain text. Built on top of @azure/storage-queue and @azure/service-bus SDKs. Active development with monthly releases. Differentiator: no config files or provider-specific code needed – just pass the provider name to the constructor.

npm install azure-abstract-queue-adapter
INSTALL
IMPORT
SIG · AZURE-ABSTRACT-QUE
A
azure-abstract-queue-adapter
devopsjavascriptv1.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AzureAbstractQueueAdapter
import AzureAbstractQueueAdapter from 'azure-abstract-queue-adapter'
const AzureAbstractQueueAdapter = require('azure-abstract-queue-adapter')
ESM default import works. CommonJS require also works, but TypeScript may need esModuleInterop.
AzureAbstractQueueAdapter (CommonJS)
const AzureAbstractQueueAdapter = require('azure-abstract-queue-adapter')
import AzureAbstractQueueAdapter from 'azure-abstract-queue-adapter'
If using CommonJS, the default export is the constructor. Named exports are not provided.
AzureAbstractQueueAdapter with TypeScript
import AzureAbstractQueueAdapter from 'azure-abstract-queue-adapter'
import { AzureAbstractQueueAdapter } from 'azure-abstract-queue-adapter'
Library uses default export only. Named import will fail.

Creates a queue, sends a JSON message, receives it, and deletes the queue using either Azure Storage Queue or Service Bus based on environment variables.

import AzureAbstractQueueAdapter from 'azure-abstract-queue-adapter'; import 'dotenv/config'; // Ensure environment variables are set (see README) const provider = process.env.AZURE_STORAGE_CONNECTION_STRING ? 'azureStorageQueue' : 'azureServiceBusMessage'; const adapter = new AzureAbstractQueueAdapter(provider); async function main() { const queueName = 'myqueue' + Date.now(); await adapter.createQueue(queueName); await adapter.createJsonMessage(queueName, { hello: 'world' }, 'msg1'); const { messageJson } = await adapter.getMessage(queueName); console.log('Received:', messageJson); await adapter.deleteQueue(queueName); } main().catch(console.error);
Debug
Known issues
breakingVersion 2.0 renamed method `createPlainMessage` to `sendMessage` and removed `messageId` parameter.
fix
Use sendMessage(queueName, queueMessage) instead of createPlainMessage.
affects: >=2.0.0
gotchaMissing environment variables for the selected provider will cause a runtime error when creating an adapter.
fix
Set AZURE_STORAGE_CONNECTION_STRING for Storage Queue or AZURE_SERVICEBUS_CONNECTION_STRING for Service Bus.
affects: *
gotchaThe `getMessage` method throws an error if the queue is empty – no empty result object.
fix
Wrap in try/catch to handle empty queue scenario.
affects: *
deprecatedMethod `createQueue` is deprecated in favor of `ensureQueue`.
fix
Use `ensureQueue(queueName, options)` which is idempotent.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: AzureAbstractQueueAdapter is not a constructor
Using named import instead of default import
fix
Use `import AzureAbstractQueueAdapter from 'azure-abstract-queue-adapter'` (default import) instead of `import { AzureAbstractQueueAdapter } from ...`
AzureAbstractQueueAdapter is not defined
Missing require/import in Node.js
fix
Add `const AzureAbstractQueueAdapter = require('azure-abstract-queue-adapter');` at the top of your file.
The queue does not exist
Trying to send/receive on a queue that hasn't been created yet
fix
Call `await adapter.createQueue(queueName);` or `await adapter.ensureQueue(queueName);` first.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies
@azure/storage-queueoptionalUsed when provider is 'azureStorageQueue'
@azure/service-busoptionalUsed when provider is 'azureServiceBusMessage'
Agent activity
14 hits · last 30 days
node
10
OpenAI (training)
2
Amazon
1
Resources
azure-abstract-queue-adapter — npm install azure-abstract-queue-adapter · libregistry