Package com.framed.interop.mqtt
Interface MqttTransport
- All Known Implementing Classes:
PahoMqttTransport
public interface MqttTransport
Minimal MQTT transport abstraction used by
MqttService. Keeps the bridge logic
independent of any particular client library, so it can be exercised with an in-memory fake in
tests and backed by PahoMqttTransport in production.-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the connection and releases resources.voidconnect()Establishes the broker connection.voidPublishes a message.voidsubscribe(String topicFilter, int qos, BiConsumer<String, byte[]> handler) Subscribes to a topic filter, delivering matching messages tohandleras(topic, payload).
-
Method Details
-
connect
Establishes the broker connection.- Throws:
Exception- if the connection cannot be established
-
publish
Publishes a message.- Parameters:
topic- the topic to publish topayload- the message payloadqos- the MQTT quality-of-service level (0/1/2)- Throws:
Exception- if publishing fails
-
subscribe
Subscribes to a topic filter, delivering matching messages tohandleras(topic, payload).- Parameters:
topicFilter- the MQTT topic filter (may contain+/#wildcards)qos- the requested QoShandler- receives(topic, payload)for each matching message- Throws:
Exception- if subscribing fails
-
close
void close()Closes the connection and releases resources.
-
