# IClientSubscribeOptions

**Kind:** Interface

**Source:** [`packages/microservices/external/mqtt-options.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/microservices/external/mqtt-options.interface.ts#L165)

**Part of:** [Microservices](subsystem-packages-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

```mermaid
graph 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

```ts
import { 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 `QoS` enum value for `qos`; 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.
