1.0.6 • Published 6 years ago

p-azure-sb v1.0.6

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

p-azure-sb

Adds a promise based API to the Azure Service Bus SDK

node npm Downloads Known Vulnerabilities

Important

Service Bus Service

These methods will block until a message is received, regardless of the timeout interval provided. The timeout will still be respected but if a message is not received in time, another request will be made. See below for rationale.

  • receiveQueueMessageAsync

  • receiveSubscriptionMessageAsync

Install

npm install p-azure-sb or yarn install p-azure-sb

Usage

Service Bus Service

import { createServiceBusService } from "p-azure-sb";

function handleResult(result) { ... }

function handleError(error) { ... }

// same arguments or environment variables
const service = createServiceBusService("my connection string");

// same arguments sans callback
// you do not get response information even if the SDK provided it
service.receiveQueueMessageAsync("my-queue")
  .then(handleResult)
  .catch(handleError);

Notification Hub Service

import { createNotificationHubService } from "p-azure-sb";

function handleResult(result) { ... }

function handleError(error) { ... }

// same arguments or environment variables
const service = createNotificationHubService("my-hub", "my connection string");

// same arguments sans callback
// you do not get response information even if the SDK provided it
service.sendAsync(null, { message: "This is a message!" })
  .then(handleResult)
  .catch(handleError);

Wrap Service

import { createWrapService } from "p-azure-sb";

function handleResult(result) { ... }

function handleError(error) { ... }

// same arguments or environment variables
const service = createWrapService("https://my.host.io", "my issuer", "my password");

// same arguments sans callback
// you do not get response information even if the SDK provided it
service.wrapAccessTokenAsync("https://my.scope.io")
  .then(handleResult)
  .catch(handleError);

Cancelling blocking requests

import azure from "p-azure-sb";

function handleResult(result) { ... }

function handleError(error) { ... }

function handleComplete() { ... }

const service = azure.createService();
const promise = service.blockingMethodAsync()
  .then(handleResult) // is NOT called
  .catch(handleError); // is NOT called
  .finally(handleComplete); // is called
...
promise.cancel();

Why block?

In the majority of cases I have come across, if a consumer does not receive a message before a timeout, the consumer is immediately going to create another request. I don't think that it should be left up to individual projects to implement this on their own.

Azure Documentation

Service Bus, unfortunately the closest thing to documentation Azure has is annotated source.

Issues

This library was generated, report issues here.

License

This source code is licensed under the MIT license found in the LICENSE.txt file.

The Azure SDK has its own license

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago