Class MqttSubscribeResult
- java.lang.Object
-
- com.plccom.mqtt.OperationResult
-
- com.plccom.mqtt.client.MqttSubscribeResult
-
- All Implemented Interfaces:
MqttSubscriptionHandle
public final class MqttSubscribeResult extends OperationResult implements MqttSubscriptionHandle
Result of a high-level subscribe operation.The result also acts as the subscription handle for the current high-level synchronous client API. This keeps common code compact:
MqttSubscriptionHandle handle = client.subscribe("plant/#") .qos1() .send(); handle.unsubscribe();Incoming MQTT messages can be received through
PlccomMqttClient.receive(long)or delivered through a listener when the subscribe builder was configured withMqttClientSubscribeBuilder.onMessage(MqttMessageListener). The same handle can be used for cleanup in both styles.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.plccom.mqtt.OperationResult
OperationResult.eQuality
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlccomMqttQualityOfServicegetMaximumQualityOfService()Returns the requested maximum QoS.StringgetTopicFilter()Returns the subscribed Topic Filter.booleanisActive()Returns whether this high-level handle has not been unsubscribed yet.MqttUnsubscribeResultunsubscribe()Unsubscribes the Topic Filter represented by this subscribe result.-
Methods inherited from class com.plccom.mqtt.OperationResult
getInnerException, getMessage, getMessage, getQuality, getResultCode, isGood, setInnerException, setMessage, setResult, setResult, setResult, toString
-
-
-
-
Method Detail
-
getTopicFilter
public String getTopicFilter()
Returns the subscribed Topic Filter.- Specified by:
getTopicFilterin interfaceMqttSubscriptionHandle- Returns:
- MQTT topic filter
-
getMaximumQualityOfService
public PlccomMqttQualityOfService getMaximumQualityOfService()
Returns the requested maximum QoS.- Returns:
- maximum QoS for matching messages
-
isActive
public boolean isActive()
Returns whether this high-level handle has not been unsubscribed yet.This is local handle state. It is updated by
unsubscribe()and is not a broker-side session query.- Specified by:
isActivein interfaceMqttSubscriptionHandle- Returns:
trueuntil this handle successfully unsubscribes
-
unsubscribe
public MqttUnsubscribeResult unsubscribe()
Unsubscribes the Topic Filter represented by this subscribe result.The first call sends the MQTT UNSUBSCRIBE request. Repeated calls are local no-ops and return a result with
MqttUnsubscribeResult.isRequestSent()set tofalse. This makes cleanup code simple while still avoiding duplicate network UNSUBSCRIBE packets from the same handle.- Specified by:
unsubscribein interfaceMqttSubscriptionHandle- Returns:
- unsubscribe result for this Topic Filter
-
-