dls-messagelibrary
v1.0.19
Published
``` npm i dls-messagelibrary ```
Downloads
4
Readme
MessageLibrary
Installation
npm i dls-messagelibrary
Usage
Publish Function
import { pushMessageToServiceBus, [YOUR_MESSAGE_MODEL_YOU_NEED] } from "dls-messagelibrary"
...
const messageBody:[YOUR_MESSAGE_MODEL_YOU_NEED] = {
// message body
}
await pushMessageToServiceBus([CONNECTION_STRING],[QUEUE_NAME], messageBody)
...
CONNECTION_STRING - You can find the connection string in google drive. Please use it in .env
QUEUE_NAME - Name of the queue you want to push a message to
NOTE: Each queue will have its dedicated message TS model. The naming convention will me that you take the queue name and make the first letter capital and add
Message
to the end. So if you for exmaple decide to push message tologging
queue, you should useLoggingMessage
as model for the message.
Logging Service
You can also take advantage of the logging service
import { LoggingService } from "dls-messagelibrary";
const loggingService = new LoggingService("EmailerService", [SERVICEBUS_STRING])
...
await loggingService.logInfo(`This is your message`, [LOG_BODY]);
...
LOG_BODY - JS object that should be stored in log
NOTE: you can also you other methods available on
loggingService
Docs links
https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-nodejs-how-to-use-queues?tabs=connection-string