Socket
Socket
Sign inDemoInstall

@vtfk/azure-servicebus-queue

Package Overview
Dependencies
115
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @vtfk/azure-servicebus-queue

High-level API for Azure Servicebus Queue operations


Version published
Maintainers
3
Created

Readme

Source

(WIP) azure-servicebus-queue

High-level API for Azure Servicebus Queue operations.

Uses the @azure/service-bus SDK

Install

npm i --save @vtfk/azure-servicebus-queue

API

Connection

Get connection string for Service Bus & names for Queues/Topics/Subscriptions

  • In the Azure Portal, go to Dashboard > Service Bus > your-servicebus-namespace.
  • Note down the "Primary Connection String" of RootManageSharedAccessKey at Shared access policies under Settings tab.
  • To work with Queues, find the "Queues" tab right under "Entities" at your-servicebus-namespace, create a Queue and note down its name.
  • To work with Topics, find the "Topics" tab right under "Entities" at your-servicebus-namespace, create a Topic. Go to your-servicebus-namespace > your-topic, create subscriptions for the topic. Note down the names of the topic and 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>'
  */
})

Service Bus operations

TODO

Subcription client operations

TODO

Topic operations

First, connect to the desired topic

const topic = serviceBusClient.topic('topicName')

Peek messages

Looks at mesages but don't delete

const limit = 6
const messages = await topic.peek(limit)

Returns an array of max 6 messages.

Peek messages by sequence number

const messages = await topic.peekBySequenceNumber('<sequenceNumber>')

Send message

const message = { body: 'message' }
await topic.send(message)

Receive message(s)

const limit = 10
const timeoutInSeconds = 1
const messages = await topic.receive(limit, timeoutInSeconds)

Send batch

const messages = [{ body: '1' }, { body: '2' }]
await topic.sendBatch(messages)

Schedule Message

const dateToSend = new Date().toISOString()
const message = { body: 'message' }
await topic.scheduleMessage(dateToSend, message)

Schedule Messages

const dateToSend = new Date().toISOString()
const messages = [{ body: '1' }, { body: '2' }]
await topic.scheduleMessages(dateToSend, messages)

Queue operations

First, connect to the desired queue

const queue = serviceBusClient.queue(queueName)

Peek messages

Looks at mesages but don't delete

const limit = 6
const messages = await queue.peek(limit)

Returns an array of max 6 messages.

Peek messages by sequence number

const messages = await queue.peekBySequenceNumber('<sequenceNumber>')

Send message

const message = { body: 'message' }
await queue.send(message)

Receive message(s)

const limit = 10
const timeoutInSeconds = 1
const messages = await queue.receive(limit, timeoutInSeconds)

Send batch

const messages = [{ body: '1' }, { body: '2' }]
await queue.sendBatch(messages)

Schedule Message

const dateToSend = new Date().toISOString()
const message = { body: 'message' }
await queue.scheduleMessage(dateToSend, message)

Schedule Messages

const dateToSend = new Date().toISOString()
const messages = [{ body: '1' }, { body: '2' }]
await queue.scheduleMessages(dateToSend, messages)

Examples

See examples/example.js

To run example.js create file .env in project root with following content

QUEUE_NAME=<queue name>
QUEUE_CONNECTION_STRING=<queue connection string url>

And run npm run example

License

MIT

Keywords

FAQs

Last updated on 11 Apr 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc