Class AbstractMqttMessageDrivenChannelAdapter
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.mqtt.inbound.AbstractMqttMessageDrivenChannelAdapter
- All Implemented Interfaces:
Aware,BeanFactoryAware,BeanNameAware,DisposableBean,InitializingBean,SmartInitializingSingleton,ApplicationContextAware,ApplicationEventPublisherAware,Lifecycle,Phased,SmartLifecycle,ExpressionCapable,MessageProducer,IntegrationPattern,NamedComponent,ManageableLifecycle,ManageableSmartLifecycle,TrackableComponent
- Direct Known Subclasses:
MqttPahoMessageDrivenChannelAdapter,Mqttv5PahoMessageDrivenChannelAdapter
@ManagedResource
@IntegrationManagedResource
public abstract class AbstractMqttMessageDrivenChannelAdapter
extends MessageProducerSupport
implements ApplicationEventPublisherAware
Abstract class for MQTT Message-Driven Channel Adapters.
- Since:
- 4.0
- Author:
- Gary Russell, Artem Bilan, Trung Pham, Mikhail Polivakha
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default completion timeout in milliseconds.protected final LockFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractMqttMessageDrivenChannelAdapter(String url, String clientId, String... topic) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a topic (or topics) to the subscribed list (qos=1).voidAdd a topic to the subscribed list.voidAdd topics to the subscribed list.protected ApplicationEventPublisherprotected Stringprotected longSubclasses may implement this method to provide component type information.protected MqttMessageConverterint[]getQos()String[]getTopic()protected StringgetUrl()protected booleanvoidremoveTopic(String... topic) Remove a topic (or topics) from the subscribed list.voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetCompletionTimeout(long completionTimeout) Set the completion timeout for operations.voidsetConverter(MqttMessageConverter converter) voidsetManualAcks(boolean manualAcks) Set the acknowledgment mode to manual.voidsetQos(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, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, onInit, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisherMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
destroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Field Details
-
DEFAULT_COMPLETION_TIMEOUT
public static final long DEFAULT_COMPLETION_TIMEOUTThe default completion timeout in milliseconds.- See Also:
-
topicLock
-
-
Constructor Details
-
AbstractMqttMessageDrivenChannelAdapter
-
-
Method Details
-
setConverter
-
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
-
getComponentType
Description copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classIntegrationObjectSupport
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin 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. Not settable using the namespace. 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
-