Class MqttService
DataPoint
model — only the wire payload is MQTT/JSON.
Outbound: discovers each configured device's channels (the standard
announceAddress/addressRegistry handshake), applies the EmissionGate, and
publishes to "<topicPrefix>/<deviceID>/<channelID>". Only mapped channels are emitted
unless includeUnmapped is set.
Inbound: for each subscribed topic, decodes the payload and republishes it as a
"<className>.<deviceID>.<channelID>.parsed" bus event.
This is a single bidirectional Service (rather than a Dispatcher + Protocol pair)
because one MQTT client connection inherently serves both directions; the Paho client is already
asynchronous, so no extra worker is needed to keep the bus handler non-blocking.
Broker availability: a broker that is down at startup is not fatal — the bridge logs a warning and a daemon thread retries connect+subscribe until it succeeds or the service stops (the deployment must not lose its MQTT leg permanently to a startup race). Once the initial connect succeeded, later connection drops are healed by the transport's automatic reconnect. Outbound publishes while disconnected fail and are dropped with a warning, throttled by the gate's interval filter.
-
Field Summary
Fields inherited from class com.framed.core.Service
ADDRESS_REGISTRY_SUFFIX, eventBus, formatter, logger -
Constructor Summary
ConstructorsConstructorDescriptionMqttService(EventBus eventBus, String id, String brokerUrl, String clientId, org.json.JSONArray devices, org.json.JSONArray subscribeTopics, String topicPrefix, int qos, String mappingPath, org.json.JSONObject gate, boolean includeUnmapped, String inboundDeviceId) Config-loadable constructor. -
Method Summary
Methods inherited from class com.framed.core.Service
addressRegistry, announceAddress, subscribeToAnnouncements
-
Constructor Details
-
MqttService
public MqttService(EventBus eventBus, String id, String brokerUrl, String clientId, org.json.JSONArray devices, org.json.JSONArray subscribeTopics, String topicPrefix, int qos, String mappingPath, org.json.JSONObject gate, boolean includeUnmapped, String inboundDeviceId) Config-loadable constructor.- Parameters:
eventBus- the event busid- the service idbrokerUrl- MQTT broker URI (e.g.tcp://127.0.0.1:1883)clientId- MQTT client iddevices- device groups whose announced channels are forwarded outboundsubscribeTopics- inbound topic filters (may be empty)topicPrefix- prefix for published topics (e.g.framed)qos- MQTT QoS for publish/subscribemappingPath- path to the interop mapping JSONgate- emission gate config (onChange,minIntervalMs)includeUnmapped- if true, publish unmapped channels too (no coded concept in payload)inboundDeviceId- device id for inbound messages whose payload/topic lacks one
-
-
Method Details
