Class AbstractMqttMessageDrivenChannelAdapter<T,C>
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.mqtt.inbound.AbstractMqttMessageDrivenChannelAdapter<T,C>
- Type Parameters:
T
- MQTT Client typeC
- MQTT connection options type (v5 or v3)
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,SmartInitializingSingleton
,ApplicationContextAware
,ApplicationEventPublisherAware
,Lifecycle
,Phased
,SmartLifecycle
,ExpressionCapable
,MessageProducer
,IntegrationPattern
,ClientManager.ConnectCallback
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
- Direct Known Subclasses:
MqttPahoMessageDrivenChannelAdapter
,Mqttv5PahoMessageDrivenChannelAdapter
@ManagedResource
@IntegrationManagedResource
public abstract class AbstractMqttMessageDrivenChannelAdapter<T,C>
extends MessageProducerSupport
implements ApplicationEventPublisherAware, ClientManager.ConnectCallback
Abstract class for MQTT Message-Driven Channel Adapters.
- Since:
- 4.0
- Author:
- Gary Russell, Artem Bilan, Trung Pham, Mikhail Polivakha, Artem Vozhdayenko
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLock
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionAbstractMqttMessageDrivenChannelAdapter
(String url, String clientId, String... topic) AbstractMqttMessageDrivenChannelAdapter
(ClientManager<T, C> clientManager, String... topic) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a topic (or topics) to the subscribed list (qos=1).void
Add a topic to the subscribed list.void
Add topics to the subscribed list.void
destroy()
protected ApplicationEventPublisher
protected String
protected ClientManager<T,
C> protected long
Subclasses may implement this method to provide component type information.protected MqttMessageConverter
protected long
int[]
getQos()
String[]
getTopic()
protected String
getUrl()
protected boolean
protected void
onInit()
Subclasses may implement this for initialization logic.void
removeTopic
(String... topic) Remove a topic (or topics) from the subscribed list.void
setApplicationEventPublisher
(ApplicationEventPublisher applicationEventPublisher) void
setCompletionTimeout
(long completionTimeout) Set the completion timeout for operations.void
setConverter
(MqttMessageConverter converter) void
setDisconnectCompletionTimeout
(long completionTimeout) Set the completion timeout when disconnecting.void
setManualAcks
(boolean manualAcks) Set the acknowledgment mode to manual.void
setQos
(int... qos) Set the QoS for each topic; a single value will apply to all topics otherwise the correct number of qos values must be provided.Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, doStart, doStop, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.integration.mqtt.core.ClientManager.ConnectCallback
connectComplete
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedType
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Field Details
-
topicLock
-
-
Constructor Details
-
AbstractMqttMessageDrivenChannelAdapter
-
AbstractMqttMessageDrivenChannelAdapter
-
-
Method Details
-
setConverter
-
getClientManager
-
setQos
public void setQos(int... qos) Set the QoS for each topic; a single value will apply to all topics otherwise the correct number of qos values must be provided.- Parameters:
qos
- The qos value(s).- Since:
- 4.1
-
getQos
-
getUrl
-
getClientId
-
getConverter
-
getTopic
-
setDisconnectCompletionTimeout
public void setDisconnectCompletionTimeout(long completionTimeout) Set the completion timeout when disconnecting. Default 5000L milliseconds.- Parameters:
completionTimeout
- The timeout.- Since:
- 5.1.10
-
getDisconnectCompletionTimeout
protected long getDisconnectCompletionTimeout() -
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classMessageProducerSupport
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
- Specified by:
destroy
in interfaceIntegrationManagement
- Overrides:
destroy
in classAbstractEndpoint
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classIntegrationObjectSupport
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
-
getApplicationEventPublisher
-
setManualAcks
public void setManualAcks(boolean manualAcks) Set the acknowledgment mode to manual.- Parameters:
manualAcks
- true for manual acks.- Since:
- 5.3
-
isManualAcks
protected boolean isManualAcks() -
setCompletionTimeout
public void setCompletionTimeout(long completionTimeout) Set the completion timeout for operations. Default 30000L milliseconds.- Parameters:
completionTimeout
- The timeout.- Since:
- 4.1
-
getCompletionTimeout
protected long getCompletionTimeout() -
addTopic
Add a topic to the subscribed list.- Parameters:
topic
- The topic.qos
- The qos.- Throws:
MessagingException
- if the topic is already in the list.- Since:
- 4.1
-
addTopic
Add a topic (or topics) to the subscribed list (qos=1).- Parameters:
topics
- The topics.- Throws:
MessagingException
- if the topics is already in the list.- Since:
- 4.1
-
addTopics
Add topics to the subscribed list.- Parameters:
topics
- The topics.qos
- The qos for each topic.- Throws:
MessagingException
- if a topics is already in the list.- Since:
- 4.1
-
removeTopic
Remove a topic (or topics) from the subscribed list.- Parameters:
topic
- The topic.- Throws:
MessagingException
- if the topic is not in the list.- Since:
- 4.1
-