Package com.plccom.mqtt.client
Class PlccomMqttSubscription
- java.lang.Object
-
- com.plccom.mqtt.client.PlccomMqttSubscription
-
public final class PlccomMqttSubscription extends Object
MQTT topic filter subscription.
-
-
Constructor Summary
Constructors Constructor Description PlccomMqttSubscription(String topicFilter, PlccomMqttQualityOfService maximumQualityOfService)Creates a subscription.PlccomMqttSubscription(String topicFilter, PlccomMqttQualityOfService maximumQualityOfService, boolean noLocal, boolean retainAsPublished, PlccomMqttRetainHandling retainHandling)Creates a subscription with MQTT 5 subscription options.PlccomMqttSubscription(String topicFilter, PlccomMqttQualityOfService maximumQualityOfService, boolean noLocal, boolean retainAsPublished, PlccomMqttRetainHandling retainHandling, Integer subscriptionIdentifier)Creates a subscription with MQTT 5 subscription options and an optional Subscription Identifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlccomMqttQualityOfServicegetMaximumQualityOfService()Returns the maximum requested QoS for matching publishes.PlccomMqttRetainHandlinggetRetainHandling()Returns the MQTT 5 Retain Handling option.IntegergetSubscriptionIdentifier()Returns the optional MQTT 5 Subscription Identifier.StringgetTopicFilter()Returns the MQTT topic filter.booleanisNoLocal()Returns whether MQTT 5 No Local was requested.booleanisRetainAsPublished()Returns whether MQTT 5 Retain As Published was requested.
-
-
-
Constructor Detail
-
PlccomMqttSubscription
public PlccomMqttSubscription(String topicFilter, PlccomMqttQualityOfService maximumQualityOfService)
Creates a subscription.- Parameters:
topicFilter- MQTT topic filtermaximumQualityOfService- requested maximum QoS- Throws:
NullPointerException- iftopicFilterormaximumQualityOfServiceisnullIllegalArgumentException- iftopicFilteris empty
-
PlccomMqttSubscription
public PlccomMqttSubscription(String topicFilter, PlccomMqttQualityOfService maximumQualityOfService, boolean noLocal, boolean retainAsPublished, PlccomMqttRetainHandling retainHandling)
Creates a subscription with MQTT 5 subscription options.The additional flags are only valid on MQTT 5 connections. A client using MQTT 3.1.1 will reject non-default MQTT 5 options before encoding the SUBSCRIBE packet.
- Parameters:
topicFilter- MQTT topic filtermaximumQualityOfService- requested maximum QoSnoLocal-trueto ask the broker not to deliver messages published by the same Client IdentifierretainAsPublished-trueto ask the broker to preserve the retained flag on forwarded Application MessagesretainHandling- retained-message replay behavior- Throws:
NullPointerException- iftopicFilter,maximumQualityOfServiceorretainHandlingisnullIllegalArgumentException- iftopicFilteris empty
-
PlccomMqttSubscription
public PlccomMqttSubscription(String topicFilter, PlccomMqttQualityOfService maximumQualityOfService, boolean noLocal, boolean retainAsPublished, PlccomMqttRetainHandling retainHandling, Integer subscriptionIdentifier)
Creates a subscription with MQTT 5 subscription options and an optional Subscription Identifier.The Subscription Identifier is sent as an MQTT 5 SUBSCRIBE property. When a broker accepts it, matching MQTT 5 PUBLISH packets include the identifier so applications can map incoming messages back to the subscription that caused the delivery. The value is only valid on MQTT 5 connections and must be in the MQTT Variable Byte Integer range
1..268435455.- Parameters:
topicFilter- MQTT topic filtermaximumQualityOfService- requested maximum QoSnoLocal-trueto ask the broker not to deliver messages published by the same Client IdentifierretainAsPublished-trueto ask the broker to preserve the retained flag on forwarded Application MessagesretainHandling- retained-message replay behaviorsubscriptionIdentifier- MQTT 5 Subscription Identifier, ornullto omit the property- Throws:
NullPointerException- iftopicFilter,maximumQualityOfServiceorretainHandlingisnullIllegalArgumentException- iftopicFilteris empty or the identifier is outside the MQTT range
-
-
Method Detail
-
getTopicFilter
public String getTopicFilter()
Returns the MQTT topic filter.- Returns:
- topic filter passed to SUBSCRIBE
-
getMaximumQualityOfService
public PlccomMqttQualityOfService getMaximumQualityOfService()
Returns the maximum requested QoS for matching publishes.- Returns:
- requested maximum QoS
-
isNoLocal
public boolean isNoLocal()
Returns whether MQTT 5 No Local was requested.- Returns:
truewhen the broker should not forward messages published by the same Client Identifier
-
isRetainAsPublished
public boolean isRetainAsPublished()
Returns whether MQTT 5 Retain As Published was requested.- Returns:
truewhen the broker should preserve the retained flag on forwarded Application Messages
-
getRetainHandling
public PlccomMqttRetainHandling getRetainHandling()
Returns the MQTT 5 Retain Handling option.- Returns:
- retained-message replay behavior
-
getSubscriptionIdentifier
public Integer getSubscriptionIdentifier()
Returns the optional MQTT 5 Subscription Identifier.- Returns:
- Subscription Identifier, or
nullwhen the SUBSCRIBE packet should not include the property
-
-