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:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.beans.factory.SmartInitializingSingleton,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationEventPublisherAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,org.springframework.integration.context.ExpressionCapable,org.springframework.integration.core.MessageProducer,org.springframework.integration.IntegrationPattern,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.ManageableLifecycle,org.springframework.integration.support.management.ManageableSmartLifecycle,org.springframework.integration.support.management.TrackableComponent
- Direct Known Subclasses:
MqttPahoMessageDrivenChannelAdapter,Mqttv5PahoMessageDrivenChannelAdapter
@ManagedResource
@IntegrationManagedResource
public abstract class AbstractMqttMessageDrivenChannelAdapter
extends org.springframework.integration.endpoint.MessageProducerSupport
implements org.springframework.context.ApplicationEventPublisherAware
Abstract class for MQTT Message-Driven Channel Adapters.
- Since:
- 4.0
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_COMPLETION_TIMEOUTThe default completion timeout in milliseconds.protected java.util.concurrent.locks.LocktopicLockFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLock -
Constructor Summary
Constructors Constructor Description AbstractMqttMessageDrivenChannelAdapter(java.lang.String url, java.lang.String clientId, java.lang.String... topic) -
Method Summary
Modifier and Type Method Description voidaddTopic(java.lang.String... topic)Add a topic (or topics) to the subscribed list (qos=1).voidaddTopic(java.lang.String topic, int qos)Add a topic to the subscribed list.voidaddTopics(java.lang.String[] topic, int[] qos)Add topics to the subscribed list.protected org.springframework.context.ApplicationEventPublishergetApplicationEventPublisher()protected java.lang.StringgetClientId()protected longgetCompletionTimeout()java.lang.StringgetComponentType()protected MqttMessageConvertergetConverter()int[]getQos()java.lang.String[]getTopic()protected java.lang.StringgetUrl()protected booleanisManualAcks()voidremoveTopic(java.lang.String... topic)Remove a topic (or topics) from the subscribed list.voidsetApplicationEventPublisher(org.springframework.context.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, toString
-
Field Details
-
DEFAULT_COMPLETION_TIMEOUT
public static final long DEFAULT_COMPLETION_TIMEOUTThe default completion timeout in milliseconds.- See Also:
- Constant Field Values
-
topicLock
protected final java.util.concurrent.locks.Lock topicLock
-
-
Constructor Details
-
AbstractMqttMessageDrivenChannelAdapter
public AbstractMqttMessageDrivenChannelAdapter(@Nullable java.lang.String url, java.lang.String clientId, java.lang.String... topic)
-
-
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
@ManagedAttribute public int[] getQos() -
getUrl
@Nullable protected java.lang.String getUrl() -
getClientId
protected java.lang.String getClientId() -
getConverter
-
getTopic
@ManagedAttribute public java.lang.String[] getTopic() -
getComponentType
public java.lang.String getComponentType()- Specified by:
getComponentTypein interfaceorg.springframework.integration.support.context.NamedComponent- Overrides:
getComponentTypein classorg.springframework.integration.context.IntegrationObjectSupport
-
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)- Specified by:
setApplicationEventPublisherin interfaceorg.springframework.context.ApplicationEventPublisherAware
-
getApplicationEventPublisher
protected org.springframework.context.ApplicationEventPublisher 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
@ManagedOperation public void addTopic(java.lang.String topic, int qos)Add a topic to the subscribed list.- Parameters:
topic- The topic.qos- The qos.- Throws:
org.springframework.messaging.MessagingException- if the topic is already in the list.- Since:
- 4.1
-
addTopic
@ManagedOperation public void addTopic(java.lang.String... topic)Add a topic (or topics) to the subscribed list (qos=1).- Parameters:
topic- The topics.- Throws:
org.springframework.messaging.MessagingException- if the topic is already in the list.- Since:
- 4.1
-
addTopics
@ManagedOperation public void addTopics(java.lang.String[] topic, int[] qos)Add topics to the subscribed list.- Parameters:
topic- The topics.qos- The qos for each topic.- Throws:
org.springframework.messaging.MessagingException- if a topic is already in the list.- Since:
- 4.1
-
removeTopic
@ManagedOperation public void removeTopic(java.lang.String... topic)Remove a topic (or topics) from the subscribed list.- Parameters:
topic- The topic.- Throws:
org.springframework.messaging.MessagingException- if the topic is not in the list.- Since:
- 4.1
-