Class HivemqV5Client
java.lang.Object
de.iip_ecosphere.platform.transport.spring.binder.hivemqv5.HivemqV5Client
A HiveMq client for all a single binder instance. Typically, different binders subscribe to different
topics.
Partially public for testing. Initial implementation, not optimized.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCalled when a message for a topic arrives. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.hivemq.client.mqtt.mqtt5.Mqtt5AsyncClientprivate HivemqV5Configurationprivate static HivemqV5Clientprivate static final de.iip_ecosphere.platform.support.logging.Loggerprivate com.hivemq.client.mqtt.datatypes.MqttQos -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateClient(HivemqV5Configuration config) Creates the client based on a given MQTT client configuration.Returns the actual configuration.static HivemqV5ClientReturns the last instance created for this class.(package private) voidSendspayloadtotopic.voidStops the client.(package private) booleansubscribeTo(String topic, HivemqV5Client.ArrivedCallback arrivedCallback) (package private) booleanunsubscribeFrom(String topic) Unsubscribes fromtopiciftopicis not blacklisted byHivemqV5Configuration.isFilteredTopic(String).
-
Field Details
-
LOGGER
private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER -
lastInstance
-
client
private com.hivemq.client.mqtt.mqtt5.Mqtt5AsyncClient client -
configuration
-
qos
private com.hivemq.client.mqtt.datatypes.MqttQos qos -
topics
-
-
Constructor Details
-
HivemqV5Client
public HivemqV5Client()Creates and registers an instance.
-
-
Method Details
-
getLastInstance
Returns the last instance created for this class. [testing]- Returns:
- the last instance
-
getConfiguration
Returns the actual configuration. [for testing]- Returns:
- the configuration, may be null
-
createClient
Creates the client based on a given MQTT client configuration.- Parameters:
config- the MQTT configuration to take the connection information from
-
stopClient
public void stopClient()Stops the client. -
subscribeTo
- Parameters:
topic- the topic to unsubscribe fromarrivedCallback- the callback to be called when a message arrived- Returns:
trueif done/successful,falseelse
-
unsubscribeFrom
Unsubscribes fromtopiciftopicis not blacklisted byHivemqV5Configuration.isFilteredTopic(String).- Parameters:
topic- the topic to unsubscribe from- Returns:
trueif done/successful,falseelse
-
send
Sendspayloadtotopic.- Parameters:
topic- the topic to send topayload- the payload to send
-