Kind: Interface
Source: packages/microservices/external/mqtt-options.interface.ts
Part of: Microservices
IClientSubscribeOptions defines configuration for MQTT topic subscriptions in the microservices transport layer. It currently specifies the Quality of Service (qos) level used when subscribing, controlling message delivery guarantees between the MQTT broker and client.
Properties
| Property | Type |
|---|---|
qos | QoS |
Diagram
mermaidgraph LR Client[MQTT Client] -->|subscribe(topic, options)| Options[IClientSubscribeOptions] Options -->|qos| QoS[MQTT QoS Level] Client --> Broker[MQTT Broker] Broker -->|messages with delivery guarantee| Client
Usage
tsimport { QoS } from 'mqtt-packet';
import type { IClientSubscribeOptions } from './mqtt-options.interface';
const subscribeOptions: IClientSubscribeOptions = {
qos: QoS.AtLeastOnce,
};
mqttClient.subscribe('devices/+/status', subscribeOptions, (error) => {
if (error) {
console.error('Unable to subscribe to device status updates', error);
}
});
AI Coding Instructions
- Provide a valid MQTT
QoSenum value forqos; do not use arbitrary numeric values unless supported by the MQTT client dependency. - Match the subscription QoS level to delivery requirements: lower levels favor performance, while higher levels provide stronger delivery guarantees.
- Pass this interface as the options object when integrating with MQTT client
subscribe()calls. - Keep subscription options transport-specific; avoid reusing MQTT QoS settings for non-MQTT microservice transports.
Was this page helpful?