# azure-sb

> Microsoft Azure Service Bus Service Library for node

Latest version **0.11.2** (published 2021-05-27) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install azure-sb
pnpm add azure-sb
yarn add azure-sb
bun add azure-sb
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.11.2 |
| Published | 2021-05-27 |
| First published | 2014-07-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | separate (@types/azure-sb) |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 299.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1174 |
| Author | Microsoft Corporation |
| Maintainers | windowsazure |
| Keywords | node, azure |

## Links

- npm: https://www.npmjs.com/package/azure-sb
- Repository: https://github.com/Azure/azure-sdk-for-node
- Homepage: http://github.com/Azure/azure-sdk-for-node
- Issues: http://github.com/Azure/azure-sdk-for-node/issues
- npm.io page: https://npm.io/package/azure-sb

## Dependencies (4)

- [wns](https://npm.io/package/wns.md) ~0.5.3
- [mpns](https://npm.io/package/mpns.md) 2.1.3
- [underscore](https://npm.io/package/underscore.md) ^1.13.1
- [azure-common](https://npm.io/package/azure-common.md) ^0.9.19

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.11.2 (latest) — 2021-05-27
- 0.11.1 — 2019-07-15
- 0.11.0 — 2019-04-08
- 0.10.6 — 2018-03-02
- 0.10.5 — 2017-09-29
- 0.10.4 — 2016-09-02
- 0.10.3 — 2016-07-05
- 0.10.2 — 2015-08-20
- 0.10.1 — 2015-06-08
- 0.10.0 — 2015-05-04
- 0.9.16 — 2015-03-25
- 0.9.15 — 2015-01-21
- 0.9.14 — 2014-11-08
- 0.9.13 — 2014-10-03
- 0.9.12 — 2014-09-10
- … 3 more at https://npm.io/package/azure-sb/versions

## README

# Microsoft Azure SDK for Node.js - Service Bus & Notification Hubs

This project provides a Node.js package `azure-sb` for accessing the below two Azure services:

- Azure Service Bus
- Azure Notification Hubs

> Please note, a newer package [@azure/service-bus](https://www.npmjs.com/package/@azure/service-bus) for Azure Service Bus is available as of May 2019. The `azure-sb` package will continue to receive critical bug fixes for features around accessing Azure Notification Hubs, but we strongly encourage you to upgrade to the new package for your Service Bus needs.

## How to Install

```bash
npm install azure-sb
```

## How to Use

```node
var azure = require('azure-sb');

function checkForMessages(sbService, queueName, callback) {
  sbService.receiveQueueMessage(queueName, { isPeekLock: true }, function (err, lockedMessage) {
    if (err) {
      if (err == 'No messages to receive') {
        console.log('No messages');
      } else {
        callback(err);
      }
    } else {
      callback(null, lockedMessage);
    }
  });
}

function processMessage(sbService, err, lockedMsg) {
  if (err) {
    console.log('Error on Rx: ', err);
  } else {
    console.log('Rx: ', lockedMsg);
    sbService.deleteMessage(lockedMsg, function(err2) {
      if (err2) {
        console.log('Failed to delete message: ', err2);
      } else {
        console.log('Deleted message.');
      }
    })
  }
}

var idx = 0;
function sendMessages(sbService, queueName) {
  var msg = 'Message # ' + (++idx);
  sbService.sendQueueMessage(queueName, msg, function (err) {
   if (err) {
     console.log('Failed Tx: ', err);
   } else {
     console.log('Sent ' + msg);
   }
  });
}

var connStr = process.argv[2] || process.env.CONNECTION_STRING;
if (!connStr) throw new Error('Must provide connection string');
var queueName = 'sbqtest';

console.log('Connecting to ' + connStr + ' queue ' + queueName);
var sbService = azure.createServiceBusService(connStr);
sbService.createQueueIfNotExists(queueName, function (err) {
  if (err) {
   console.log('Failed to create queue: ', err);
  } else {
   setInterval(checkForMessages.bind(null, sbService, queueName, processMessage.bind(null, sbService)), 5000);
   setInterval(sendMessages.bind(null, sbService, queueName), 15000);
  }
});
```
Thanks to [@noodlefrenzy](https://github.com/noodlefrenzy) for the great example. The original is [here](https://github.com/noodlefrenzy/node-cerulean/blob/master/examples/servicebus_send_receive.js).

## Related projects

- [Microsoft Azure SDK for Node.js](https://github.com/WindowsAzure/azure-sdk-for-node)


![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-node%2Flib%2Fservices%2FserviceBus%2FREADME.png)

---
_Source: https://npm.io/package/azure-sb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
