# MQTT Consumer

The **MQTT (Message Queuing Telemetry Transport) Consumer** is a lightweight, publish-subscribe client designed to consume messages from an **MQTT broker**.

It is optimized for environments with **low bandwidth, high latency, or resource-constrained devices**, making it widely used in **Internet of Things (IoT)** applications.

The component subscribes to defined MQTT topics and consumes messages with configurable Quality of Service (QoS) levels.

### Configuration Sections

All configurations are classified into the following sections:

* **Basic Information**
* **Meta Information**
* **Resource Configuration**
* **Connection Validation**

### Basic Information Tab

The *Basic Information* tab defines general execution settings.

| Field                       | Description                                                               | Required |
| --------------------------- | ------------------------------------------------------------------------- | -------- |
| **Invocation Type**         | Select execution mode: **Batch** or **Real-Time**.                        | Yes      |
| **Deployment Type**         | Displays the deployment type of the component (pre-selected).             | Yes      |
| **Container Image Version** | Displays the Docker image version used (pre-selected).                    | Yes      |
| **Failover Event**          | Select a failover event to handle retries or errors.                      | Optional |
| **Batch Size**              | Maximum number of records processed in one execution cycle (minimum: 10). | Yes      |

### Meta Information Tab

The *Meta Information* tab configures the MQTT broker connection, authentication, and topic subscription.

| Field                        | Description                                                                                               | Required    |
| ---------------------------- | --------------------------------------------------------------------------------------------------------- | ----------- |
| **Host IP Address**          | IP address of the MQTT broker.                                                                            | Yes         |
| **Username**                 | Username for authentication.                                                                              | Conditional |
| **Port**                     | Port of the MQTT broker (default: **1883** for non-SSL, **8883** for SSL).                                | Yes         |
| **Authenticator**            | Authentication method: **Password** or **PEM/PPK File**.                                                  | Yes         |
| **Password**                 | Password for authentication (used if *Password* method is selected).                                      | Conditional |
| **PEM/PPK File**             | Upload PEM/PPK key file for secure authentication (if selected).                                          | Conditional |
| **Quality of Service (QoS)** | Defines message delivery guarantee: **0 (At most once)**, **1 (At least once)**, or **2 (Exactly once)**. | Yes         |
| **MQTT Topic**               | Name of the topic from which to consume published messages.                                               | Yes         |

### Quality of Service (QoS) Levels

The MQTT Consumer supports three **QoS levels**, which define delivery guarantees between broker and client:

| QoS Level             | Delivery Guarantee                       | Description                                                                  |
| --------------------- | ---------------------------------------- | ---------------------------------------------------------------------------- |
| **0 – At most once**  | Best-effort delivery, no acknowledgment. | Messages may be lost if the connection fails.                                |
| **1 – At least once** | Guaranteed delivery **≥1 time**.         | Messages are re-sent until acknowledgment is received. Duplicates may occur. |
| **2 – Exactly once**  | Guaranteed delivery **only once**.       | Highest reliability, but slower due to 4-step handshake.                     |

### Workflow Steps

To run a pipeline workflow with the MQTT Consumer:

1. Drag and drop the **MQTT Consumer** component into the **Pipeline Workflow Editor**.
2. Configure the **Basic Information** and **Meta Information** tabs.
3. Click **Save Component** (Storage icon).
4. Update and activate the **Pipeline Workflow**.
5. Monitor activity in the **Logs panel** to verify message consumption when the pipeline starts.

### Example Workflow

1. Connect the MQTT Consumer to a broker running at `192.168.1.20` on port `1883`.
2. Set **QoS** to `1 (At least once)` for reliable delivery.
3. Subscribe to the topic `iot/sensors/temperature`.
4. When the pipeline runs, the consumer retrieves temperature readings published by IoT devices and forwards them to downstream events for analysis.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bdb.ai/bdb-user-documentation/platform-modules/11.0/data-engineering/data-pipelines/pipeline-editor/pipeline-components/consumers/mqtt-consumer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
