Class AbstractMqttClientManager<T,C>
java.lang.Object
org.springframework.integration.mqtt.core.AbstractMqttClientManager<T,C>
- Type Parameters:
T
- MQTT client typeC
- MQTT connection options type (v5 or v3)
- All Implemented Interfaces:
Aware
,BeanNameAware
,ApplicationEventPublisherAware
,Lifecycle
,Phased
,SmartLifecycle
,ClientManager<T,
,C> MqttComponent<C>
- Direct Known Subclasses:
Mqttv3ClientManager
,Mqttv5ClientManager
public abstract class AbstractMqttClientManager<T,C>
extends Object
implements ClientManager<T,C>, ApplicationEventPublisherAware
Abstract class for MQTT client managers which can be a base for any common v3/v5 client manager implementation.
Contains some basic utility and implementation-agnostic fields and methods.
- Since:
- 6.0
- Author:
- Artem Vozhdayenko, Artem Bilan, Christian Tzolov
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.mqtt.core.ClientManager
ClientManager.ConnectCallback
-
Field Summary
Fields inherited from interface org.springframework.integration.mqtt.core.ClientManager
DEFAULT_COMPLETION_TIMEOUT, DISCONNECT_COMPLETION_TIMEOUT
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCallback
(ClientManager.ConnectCallback connectCallback) Register a callback for theconnectComplete
event from the client.protected ApplicationEventPublisher
Return this component's bean name.protected Set<ClientManager.ConnectCallback>
Return the managed client.protected String
protected long
protected long
int
getPhase()
The phase of component auto-start inSmartLifecycle
.protected String
getUrl()
boolean
If manual acknowledge has to be used; false by default.boolean
boolean
removeCallback
(ClientManager.ConnectCallback connectCallback) Remove the callback from registration.void
setApplicationEventPublisher
(ApplicationEventPublisher applicationEventPublisher) void
setBeanName
(String name) protected void
void
setCompletionTimeout
(long completionTimeout) Set the completion timeout for operations.void
setDisconnectCompletionTimeout
(long completionTimeout) Set the completion timeout when disconnecting.void
setManualAcks
(boolean manualAcks) void
setPhase
(int phase) Set the phase of component autostart inSmartLifecycle
.protected void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.integration.mqtt.core.ClientManager
isConnected
Methods inherited from interface org.springframework.integration.mqtt.core.MqttComponent
getConnectionInfo
Methods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup, stop
-
Field Details
-
logger
-
lock
-
-
Constructor Details
-
AbstractMqttClientManager
-
-
Method Details
-
setManualAcks
public void setManualAcks(boolean manualAcks) -
getUrl
-
setUrl
-
getClientId
-
getApplicationEventPublisher
-
setClient
-
getCallbacks
-
setCompletionTimeout
public void setCompletionTimeout(long completionTimeout) Set the completion timeout for operations. Default 30000L milliseconds.- Parameters:
completionTimeout
- The timeout.- Since:
- 6.0.3
-
getCompletionTimeout
protected long getCompletionTimeout() -
setDisconnectCompletionTimeout
public void setDisconnectCompletionTimeout(long completionTimeout) Set the completion timeout when disconnecting. Default 5000L milliseconds.- Parameters:
completionTimeout
- The timeout.- Since:
- 6.0.3
-
getDisconnectCompletionTimeout
protected long getDisconnectCompletionTimeout() -
isManualAcks
public boolean isManualAcks()Description copied from interface:ClientManager
If manual acknowledge has to be used; false by default.- Specified by:
isManualAcks
in interfaceClientManager<T,
C> - Returns:
- true if manual acknowledge has to be used.
-
getClient
Description copied from interface:ClientManager
Return the managed client.- Specified by:
getClient
in interfaceClientManager<T,
C> - Returns:
- the managed client.
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
-
setBeanName
- Specified by:
setBeanName
in interfaceBeanNameAware
-
getBeanName
Description copied from interface:MqttComponent
Return this component's bean name.- Specified by:
getBeanName
in interfaceMqttComponent<T>
- Returns:
- the bean name.
-
getPhase
public int getPhase()The phase of component auto-start inSmartLifecycle
. If the custom one is required, note that for the correct behavior it should be less than phase ofAbstractMqttMessageDrivenChannelAdapter
implementations. The default phase isDEFAULT_MANAGER_PHASE
.- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
- Returns:
SmartLifecycle
autostart phase- See Also:
-
addCallback
Description copied from interface:ClientManager
Register a callback for theconnectComplete
event from the client.- Specified by:
addCallback
in interfaceClientManager<T,
C> - Parameters:
connectCallback
- aClientManager.ConnectCallback
to register.
-
removeCallback
Description copied from interface:ClientManager
Remove the callback from registration.- Specified by:
removeCallback
in interfaceClientManager<T,
C> - Parameters:
connectCallback
- aClientManager.ConnectCallback
to unregister.- Returns:
- true if callback was removed.
-
isRunning
public boolean isRunning() -
setPhase
public void setPhase(int phase) Set the phase of component autostart inSmartLifecycle
. If the custom one is required, note that for the correct behavior it should be less than phase ofAbstractMqttMessageDrivenChannelAdapter
implementations.- See Also:
-