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 interface
A contract for a custom callback onconnectComplete
event from the client. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
The default completion timeout in milliseconds.static final long
The default disconnect completion timeout in milliseconds.Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCallback
(ClientManager.ConnectCallback connectCallback) Register a callback for theconnectComplete
event from the client.Return the managed client.boolean
Return the managed clients isConnected.boolean
If manual acknowledge has to be used; false by default.boolean
removeCallback
(ClientManager.ConnectCallback connectCallback) Remove the callback from registration.Methods inherited from interface org.springframework.beans.factory.BeanNameAware
setBeanName
Methods inherited from interface org.springframework.integration.mqtt.core.MqttComponent
getBeanName, getConnectionInfo
Methods 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 theconnectComplete
event from the client.- Parameters:
connectCallback
- aClientManager.ConnectCallback
to register.
-
removeCallback
Remove the callback from registration.- Parameters:
connectCallback
- aClientManager.ConnectCallback
to unregister.- Returns:
- true if callback was removed.
-
isConnected
boolean isConnected()Return the managed clients isConnected.- Returns:
- the managed clients isConnected.
- Since:
- 6.4
-