@imaness/bus-azure-service-bus
v1.0.0
Published
An Azure Service Bus transport adapter for @node-ts/bus-core.
Downloads
7
Maintainers
Readme
@imaness/bus-azure-service-bus
An Azure Service Bus queue adapter for @node-ts/bus
🔥 View our docs at https://bus.node-ts.com 🔥
🤔 Have a question? Join our Discord 🤔
Installation
Install packages and their dependencies
npm i @imaness/bus-azure-service-bus @node-ts/bus-core
Once installed, configure Bus to use this transport during initialization:
import { Bus } from '@node-ts/bus-core'
import { ServiceBusTransport, ServiceBusTransportConfiguration } from '@imaness/bus-azure-service-bus'
// For Using Service Bus Queue
const sbQueueConfiguration: ServiceBusTransportConfiguration = {
queueName: {Queue Name},
serviceBusClient: new ServiceBusClient(),
}
const sbQueueTransport = new ServiceBusTransport(sbConfiguration)
// For Using Service Bus Topic
const sbTopicSubscriptionConfiguration: ServiceBusTransportConfiguration = {
topicName: {Topic Name},
subscriptionName: {Subscription Name},
serviceBusClient: new ServiceBusClient()
}
const sbTopicTransport = new ServiceBusTransport(sbConfiguration)
// Configure Bus to use Azure Service Bus Queue as a transport
const run = async () => {
await Bus
.configure()
.withTransport({ sbQueueTransport or sbTopicTransport })
.initialize()
}
run.catch(console.error)
Mapping of ApplicationProperties to Attributes and StickyAttributes
Azure Service Bus supports Message Properties.
In order for you to map it to Attributes or StickyAttributes you need to add key prefix of either attributes
or stickyAttributes
. Those key that are not have the said prefixes will be considered as attributes
.