Ir para o conteúdo

MQTT Message Archive

Responsibility

MongoMqttMessageStore archives the full MqttEnvelope and original MQTT topic for every envelope delivered to the admin process. MqttTrafficMonitorService subscribes to MQTT # for this passive archive while retaining its existing typed subscriptions for the live monitor. The archive is independent of the 500-message in-memory display buffer and does not replace DataComponent or the local time-series SQLite store.

Topic coverage

The archive wildcard includes the documented federated fl/ topics, canonical IoT iot/ topics, CDDL mhub/ service topics and microbroker/cddl/event/object/+ event topics. Stored documents contain the original topic, receipt timestamp, selected envelope metadata and the complete envelope JSON (including payload, hash and signature). The archive observes messages; it does not validate signatures or payload integrity, which remains the responsibility of the protocol consumers.

It archives live envelopes delivered while the monitor's MQTT client is connected. The current gateway uses a clean MQTT session, so it does not recover messages published while the monitor was offline; messages that are not retained by the broker are not backfilled. This is an application subscriber archive, not a broker-side audit log.

Configuration

Archiving is enabled when MQTT_ARCHIVE_MONGODB_URI is set. Optional settings:

Variable Default Meaning
MQTT_ARCHIVE_MONGODB_URI disabled MongoDB connection URI
MQTT_ARCHIVE_MONGODB_DATABASE hdt_af Database name
MQTT_ARCHIVE_MONGODB_COLLECTION mqtt_messages Collection name

The MongoDB Java Sync Driver is used. Documents are append-only; no TTL or deletion policy is currently applied. MongoDB must be reachable from the admin process. Insert errors are logged and isolated from other MQTT subscribers.

Privacy and retention

The collection stores the complete payload. This includes sensor values on iot/ and mhub/ topics, which are otherwise ingested locally by the client's DataComponent. Deploy this archive only where that central retention is authorized, protect MongoDB credentials and network access, and define an operational retention/deletion policy before processing personal or health data.

Implementation

  • MqttMessageStore: persistence port.
  • MongoMqttMessageStore: MongoDB implementation and environment configuration.
  • StoredMqttMessage: topic, receipt timestamp and complete envelope.
  • MqttTrafficMonitorService: wildcard archive subscription plus existing live-monitor flow.