Azure Service Bus
Azure Service Bus Integration
This guide explains how to configure and use Azure Service Bus in your messaging-based application using
@nestjstools/messaging.
π¦ Installation
Make sure youβve installed the following dependencies:
npm install @nestjstools/messaging @nestjstools/messaging-azure-service-bus-extension
or
yarn add @nestjstools/messaging @nestjstools/messaging-azure-service-bus-extensionπ οΈ Channel Configuration
Basic Setup queue
channels: [
new AzureServiceBusChannelConfig({
name: 'azure-channel',
connectionString: 'Endpoint=sb://your-namespace.servicebus.windows.net/;SharedAccessKeyName=...;',
queue: 'your-queue-name',
autoCreate: false, // Requires admin permission
enableConsumer: true,
}),
],Topic/Subscription Example
βοΈ Config Options
name
Internal channel name
β
connectionString
Azure Service Bus connection string
β
queue
Queue name (required for Mode.QUEUE)
β
topic
Topic name (required for Mode.TOPIC)
β
subscription
Subscription name (required for Mode.TOPIC)
β
mode
'queue' or 'topic'
'queue'
autoCreate
Auto-create queue/topic/subscription (requires admin permissions)
false
enableConsumer
Enable message receiving
true
π€ Dispatching a Message
β Tips
autoCreateworks only if the channel hasenableConsumer = trueand the connection string has management permissions.Use
mode: Mode.TOPIConly when usingtopicandsubscription.
Last updated
Was this helpful?