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 type
C - MQTT connection options type (v5 or v3)
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, ClientManager.ConnectCallback, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationInboundManagement, org.springframework.integration.support.management.IntegrationManagement, 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<T,C> extends org.springframework.integration.endpoint.MessageProducerSupport implements org.springframework.context.ApplicationEventPublisherAware, ClientManager.ConnectCallback
Abstract class for MQTT Message-Driven Channel Adapters.
Since:
4.0
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    The default completion timeout in milliseconds.
    protected final Lock
     

    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

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTopic(String... topic)
    Add a topic (or topics) to the subscribed list (qos=1).
    void
    addTopic(String topic, int qos)
    Add a topic to the subscribed list.
    void
    addTopics(String[] topic, int[] qos)
    Add topics to the subscribed list.
    void
     
    protected org.springframework.context.ApplicationEventPublisher
     
    protected String
     
    protected ClientManager<T,C>
     
    protected long
     
     
     
    int[]
     
     
    protected String
     
    protected boolean
     
    protected void
     
    void
    removeTopic(String... topic)
    Remove a topic (or topics) from the subscribed list.
    void
    setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
     
    void
    setCompletionTimeout(long completionTimeout)
    Set the completion timeout for operations.
    void
     
    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, getIntegrationProperty, 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

    • DEFAULT_COMPLETION_TIMEOUT

      public static final long DEFAULT_COMPLETION_TIMEOUT
      The default completion timeout in milliseconds.
      See Also:
    • topicLock

      protected final Lock topicLock
  • Constructor Details

    • AbstractMqttMessageDrivenChannelAdapter

      public AbstractMqttMessageDrivenChannelAdapter(@Nullable String url, String clientId, String... topic)
    • AbstractMqttMessageDrivenChannelAdapter

      public AbstractMqttMessageDrivenChannelAdapter(ClientManager<T,C> clientManager, String... topic)
  • Method Details

    • setConverter

      public void setConverter(MqttMessageConverter converter)
    • getClientManager

      @Nullable protected ClientManager<T,C> 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

      @ManagedAttribute public int[] getQos()
    • getUrl

      @Nullable protected String getUrl()
    • getClientId

      @Nullable protected String getClientId()
    • getConverter

      protected MqttMessageConverter getConverter()
    • getTopic

      @ManagedAttribute public String[] getTopic()
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.endpoint.MessageProducerSupport
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
      Specified by:
      destroy in interface org.springframework.integration.support.management.IntegrationManagement
      Overrides:
      destroy in class org.springframework.integration.endpoint.AbstractEndpoint
    • getComponentType

      public String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.context.IntegrationObjectSupport
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
      Specified by:
      setApplicationEventPublisher in interface org.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(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(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(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(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