# MQTT Messages

> The MQTT topics Collection publishes Devices, Observations, Statistics, and Connection Status to.

URL: https://www.trakhound.com/docs/mtconnect-server/messages

Messages Profiles publish the data of their Devices to an MQTT broker as JSON. Messages are **retained**, so a client that subscribes receives the latest message on each topic right away, and then each new one as it's collected.

## Topics

Each Profile publishes under its **Base Topic** (`trakhound/mtconnect/collection` when left blank):

| Topic | Contents |
| --- | --- |
| `{baseTopic}/devices/{deviceUuid}/device` | The Device model |
| `{baseTopic}/devices/{deviceUuid}/component/{componentId}` | Each Component |
| `{baseTopic}/devices/{deviceUuid}/data_item/{dataItemId}` | Each DataItem |
| `{baseTopic}/observations/{deviceUuid}/{dataItemId}` | The Observations of each DataItem that matches the Profile's [Filter](https://www.trakhound.com/docs/mtconnect-server/filters) |
| `{baseTopic}/statistics/{deviceUuid}/device` | Observation statistics of the Device |
| `{baseTopic}/statistics/{deviceUuid}/data_item/{dataItemId}` | Observation statistics of each DataItem |
| `{baseTopic}/connections/{deviceId}/status` | The Device's Connection Status |

## Subscribe

With the default Base Topic:

| Subscription | Receives |
| --- | --- |
| `trakhound/mtconnect/collection/observations/#` | Every Observation of every Device |
| `trakhound/mtconnect/collection/observations/{deviceUuid}/#` | Every Observation of one Device |
| `trakhound/mtconnect/collection/observations/+/{dataItemId}` | One DataItem ID on every Device |
| `trakhound/mtconnect/collection/connections/#` | The Connection Status of every Device |

For example, with the Mosquitto command line client:

```bash
mosquitto_sub -h localhost -t "trakhound/mtconnect/collection/observations/#" -v
```

## Observation Messages

An Observation message is an Observation Collection: the DataItem's ID and its values, in one of three lists depending on its Category (the same format as the [REST API](https://www.trakhound.com/docs/mtconnect-server/api#current)):

```json
{
  "dataItemId": "execution",
  "eventValue": [
    { "result": "ACTIVE", "timestamp": "2026-10-08T14:35:00.0000000Z", "sequence": 102400 }
  ]
}
```

| List | Used For |
| --- | --- |
| `sampleValue` | Numeric SAMPLEs, with a numeric `result` |
| `eventValue` | EVENTs, with a text `result` |
| `condition` | CONDITIONs, with a `level`, `nativeCode`, and the alarm message as `result` |

## Several Profiles on One Broker

Profiles with different Base Topics can publish to the same MQTT broker. For example, publish Conditions under `plant1/alarms` with one Profile (a Filter that allows `category=CONDITION`), and all other Observations under `plant1/data` with another.

> The REST API's [WebSocket stream](https://www.trakhound.com/docs/mtconnect-server/api#streaming) is built on the Messages published with the default Base Topic, through the **default** Router.
