Interface ClientManager<T,C>
- Type Parameters:
T- MQTT client typeC- MQTT connection options type (v5 or v3)
- All Superinterfaces:
Aware,BeanNameAware,Lifecycle,MqttComponent<C>,Phased,SmartLifecycle
- All Known Implementing Classes:
AbstractMqttClientManager,Mqttv3ClientManager,Mqttv5ClientManager
A utility abstraction over MQTT client which can be used in any MQTT-related component
without need to handle generic client callbacks, reconnects etc.
Using this manager in multiple MQTT integrations will preserve a single connection.
- Since:
- 6.0
- Author:
- Artem Vozhdayenko, Artem Bilan, Jiri Soucek
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA contract for a custom callback onconnectCompleteevent from the client. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default completion timeout in milliseconds.static final longThe default disconnect completion timeout in milliseconds.Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallback(ClientManager.ConnectCallback connectCallback) Register a callback for theconnectCompleteevent from the client.Return the managed client.booleanReturn the managed clients isConnected.booleanIf manual acknowledge has to be used; false by default.booleanremoveCallback(ClientManager.ConnectCallback connectCallback) Remove the callback from registration.Methods inherited from interface org.springframework.beans.factory.BeanNameAware
setBeanNameMethods inherited from interface org.springframework.integration.mqtt.core.MqttComponent
getBeanName, getConnectionInfoMethods inherited from interface org.springframework.context.SmartLifecycle
getPhase, isAutoStartup, stop
-
Field Details
-
DEFAULT_COMPLETION_TIMEOUT
static final long DEFAULT_COMPLETION_TIMEOUTThe default completion timeout in milliseconds.- See Also:
-
DISCONNECT_COMPLETION_TIMEOUT
static final long DISCONNECT_COMPLETION_TIMEOUTThe default disconnect completion timeout in milliseconds.- See Also:
-
-
Method Details
-
getClient
-
isManualAcks
boolean isManualAcks()If manual acknowledge has to be used; false by default.- Returns:
- true if manual acknowledge has to be used.
-
addCallback
Register a callback for theconnectCompleteevent from the client.- Parameters:
connectCallback- aClientManager.ConnectCallbackto register.
-
removeCallback
Remove the callback from registration.- Parameters:
connectCallback- aClientManager.ConnectCallbackto unregister.- Returns:
- true if callback was removed.
-
isConnected
boolean isConnected()Return the managed clients isConnected.- Returns:
- the managed clients isConnected.
- Since:
- 6.4
-