Giter Site home page Giter Site logo

azure-sb-queue-watcher's Introduction

Azure SB Queue Watcher

Dependency Status devDependency Status

Job worker around Azure Service Bus Queues. It exposes a clean interface to watch for messages in a failsafe way.

Azure/azure-sdk-for-node does not exposes a simple way to watch for messages and mark them as completed.

This is the reason to exist of this module.

Install

npm install azure-sb-queue-watcher --save

Example

var azure = require('azure');
var AzureSBQueueWatcher = require('azure-sb-queue-watcher');

var myServiceBus = azure.createServiceBusService();
var watcher = new AzureSBQueueWatcher({
  serviceBus: myServiceBus,
  queueName: 'hello'
});

watcher.start();

watcher.on('message', newMessage);
watcher.on('error', console.error);

function newMessage(message, done) {
  console.log(message);
  
  // fake async processing
  setTimeout(done, 200);
}

API

var watcher = new AzureSBQueueWatcher(opts)

opts.serviceBus is required and must be a ServiceBusService object.

You usually create them like this:

var azure = require('azure');
var serviceBusService = azure.createServiceBusService();

opts.queueName is the service bus queue name you want to watch.

opts.concurrency is the number of messages you want to get from the queue at once. It defaults to 1. It all depends on how much messages you can deal with given you CPU power.

opts.timeout is the message processing timeout (in ms). After this timeout, the message is released to be consumed by others. Defaults to 30s.

watcher.start()

Start watching for messages.

watcher.stop()

Stop watching for messages.

watcher.on('message', message, done)

New message arrived.

message contains the original azure service bus queue message.

done is a callback you must call when you have finished dealing with the message. You must call done.

watcher.on('error')

Emitted when an error occurs. Error cases:

azure-sb-queue-watcher's People

Contributors

vvo avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

azure-sb-queue-watcher's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.