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
FieldsModifier and TypeFieldDescriptionprotected final Lockprotected final org.apache.commons.logging.LogFields inherited from interface org.springframework.integration.mqtt.core.ClientManager
DEFAULT_COMPLETION_TIMEOUT, DISCONNECT_COMPLETION_TIMEOUT, QUIESCENT_TIMEOUTFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallback(ClientManager.ConnectCallback connectCallback) Register a callback for theconnectCompleteevent from the client.protected ApplicationEventPublisherReturn this component's bean name.protected Set<ClientManager.ConnectCallback> @Nullable TReturn the managed client.Return the managed client id.protected longprotected longintgetPhase()The phase of component auto-start inSmartLifecycle.protected longgetUrl()Return the managed client url.booleanIf manual acknowledge has to be used; false by default.booleanbooleanremoveCallback(ClientManager.ConnectCallback connectCallback) Remove the callback from registration.voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetBeanName(String name) protected voidvoidsetCompletionTimeout(long completionTimeout) Set the completion timeout for operations.voidsetDisconnectCompletionTimeout(long completionTimeout) Set the completion timeout when disconnecting.voidsetManualAcks(boolean manualAcks) voidsetPhase(int phase) Set the phase of component autostart inSmartLifecycle.voidsetQuiescentTimeout(long quiescentTimeout) Set the quiescentTimeout timeout when disconnecting.protected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.integration.mqtt.core.ClientManager
isConnectedMethods inherited from interface org.springframework.integration.mqtt.core.MqttComponent
getConnectionInfoMethods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup, isPauseable, stop
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger -
lock
-
-
Constructor Details
-
AbstractMqttClientManager
-
-
Method Details
-
setManualAcks
public void setManualAcks(boolean manualAcks) -
getUrl
Description copied from interface:ClientManagerReturn the managed client url.- Specified by:
getUrlin interfaceClientManager<T,C> - Returns:
- the managed client url, never null.
-
setUrl
-
getClientId
Description copied from interface:ClientManagerReturn the managed client id.- Specified by:
getClientIdin interfaceClientManager<T,C> - Returns:
- the managed client id, never null.
-
getApplicationEventPublisher
-
setClient
-
getCallbacks
-
setCompletionTimeout
-
getCompletionTimeout
protected long getCompletionTimeout() -
setDisconnectCompletionTimeout
-
getDisconnectCompletionTimeout
protected long getDisconnectCompletionTimeout() -
setQuiescentTimeout
public void setQuiescentTimeout(long quiescentTimeout) Set the quiescentTimeout timeout when disconnecting. Default isClientManager.QUIESCENT_TIMEOUTmilliseconds.- Parameters:
quiescentTimeout- The timeout.- Since:
- 7.0.0
-
getQuiescentTimeout
protected long getQuiescentTimeout() -
isManualAcks
public boolean isManualAcks()Description copied from interface:ClientManagerIf manual acknowledge has to be used; false by default.- Specified by:
isManualAcksin interfaceClientManager<T,C> - Returns:
- true if manual acknowledge has to be used.
-
getClient
Description copied from interface:ClientManagerReturn the managed client.- Specified by:
getClientin interfaceClientManager<T,C> - Returns:
- the managed client.
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware
-
setBeanName
- Specified by:
setBeanNamein interfaceBeanNameAware
-
getBeanName
Description copied from interface:MqttComponentReturn this component's bean name.- Specified by:
getBeanNamein 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 ofAbstractMqttMessageDrivenChannelAdapterimplementations. The default phase isDEFAULT_MANAGER_PHASE.- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle- Returns:
SmartLifecycleautostart phase- See Also:
-
addCallback
Description copied from interface:ClientManagerRegister a callback for theconnectCompleteevent from the client.- Specified by:
addCallbackin interfaceClientManager<T,C> - Parameters:
connectCallback- aClientManager.ConnectCallbackto register.
-
removeCallback
Description copied from interface:ClientManagerRemove the callback from registration.- Specified by:
removeCallbackin interfaceClientManager<T,C> - Parameters:
connectCallback- aClientManager.ConnectCallbackto unregister.- Returns:
- true if callback was removed.
-
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 ofAbstractMqttMessageDrivenChannelAdapterimplementations.- See Also:
-