2.0.3 • Published 4 years ago

@juntoz/azure-service-bus-sender v2.0.3

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

azure-service-bus-sender

Wrapper for Azure Service Bus to send messages to topics and queues.

This library was created to provide a singleton for bus client, topic client and sender to be able to reuse them which is the recommended pattern (expensive objects).

Install

npm install @juntoz/azure-service-bus-sender

Use it

const ASBWrapper = require('@juntoz/azure-service-bus-sender');

// create a singleton, this is important because asb is a expensive object
var asb = new ASBWrapper();

async function main_azfunc() {
    // NOTE: the bus name is important because it is the key to cache the clients.
    var busName;
    var busConnectionString, busTopicName, busQueueName;

    // create or reuse the topic sender
    var ts = asb.createTopicSender(busName, busConnectionString, busTopicName);

    // send the message
    await ts.send(myMsg);

    // create or reuse the queue sender
    var qs = asb.createQueueSender(busName, busConnectionString, busQueueName);

    // send the message
    await qs.send(myMsg);
}

module.exports = main_azfunc;

Cleanup

The class also has a cleanup method which can be called to close the bus client connections. In Azure Functions, this is not really needed to be called, however, if this is used outside AzF, then you should call it at the end of the application.

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago