Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
@vtfk/azure-servicebus-queue
Advanced tools
High-level API for Azure Servicebus Queue operations
High-level API for Azure Servicebus Queue operations.
Supports to send and receive messages >64kb by storing and retrieving from blob storage.
Uses the @azure/service-bus SDK
npm i --save @vtfk/azure-servicebus-queue
Get connection string for Service Bus & names for Queues/Topics/Subscriptions
const serviceBusClient = require('@vtfk/azure-servicebus-queue')({
connectionString: '<Servicebus Connection String>'
/* Uncomment to send and receive messages >64kb
storageConnectionString: '<Blob Service SAS URL>'
storageContainerName: '<Container name>'
*/
})
TODO
TODO
First, connect to the desired topic
const topic = serviceBusClient.topic('topicName')
Looks at mesages but don't delete
const limit = 6
const messages = await topic.peek(limit)
Returns an array of max 6 messages.
const messages = await topic.peekBySequenceNumber('<sequenceNumber>')
const message = { body: 'message' }
await topic.send(message)
const limit = 10
const timeoutInSeconds = 1
const messages = await topic.receive(limit, timeoutInSeconds)
const messages = [{ body: '1' }, { body: '2' }]
await topic.sendBatch(messages)
const dateToSend = new Date().toISOString()
const message = { body: 'message' }
await topic.scheduleMessage(dateToSend, message)
const dateToSend = new Date().toISOString()
const messages = [{ body: '1' }, { body: '2' }]
await topic.scheduleMessages(dateToSend, messages)
First, connect to the desired queue
const queue = serviceBusClient.queue(queueName)
Looks at mesages but don't delete
const limit = 6
const messages = await queue.peek(limit)
Returns an array of max 6 messages.
const messages = await queue.peekBySequenceNumber('<sequenceNumber>')
const message = { body: 'message' }
await queue.send(message)
const limit = 10
const timeoutInSeconds = 1
const messages = await queue.receive(limit, timeoutInSeconds)
const messages = [{ body: '1' }, { body: '2' }]
await queue.sendBatch(messages)
const dateToSend = new Date().toISOString()
const message = { body: 'message' }
await queue.scheduleMessage(dateToSend, message)
const dateToSend = new Date().toISOString()
const messages = [{ body: '1' }, { body: '2' }]
await queue.scheduleMessages(dateToSend, messages)
Inside storage you will find readBigMessage
and sendBigMessage
.
These will use the storageConnectionString
and storageContainerName
arguments to get the correct blob.
Store a message and get the ID in return.
const message = 'A message that is to big for the servicebus queue'
const fileId = await serviceBusClient.storage.sendBigMessage(message)
Reads a message from the configured blob storage with a specified ID.
Useful if a function binding is used for listening to new messages.
const fileId = '5266176d-dc5f-4304-b87e-5a4ef78a29b1.json'
const message = await serviceBusClient.storage.readBigMessage(fileId)
Returns the content of the blob with that ID.
To run example.js
create file .env
in project root with following content
QUEUE_NAME=<queue name>
QUEUE_CONNECTION_STRING=<Servicebus Connection String>
BLOB_SERVICE_SAS_URL=<Blob Service SAS URL> # Only needed for bigfile example
BLOB_CONTAINER_NAME=<Container name> # Only needed for bigfile example
And run npm run example
or npm run example-bigfile
(to test with messages >64kb)
FAQs
High-level API for Azure Servicebus Queue operations
We found that @vtfk/azure-servicebus-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.