Class MqttPahoMessageDrivenChannelAdapter

All Implemented Interfaces:
org.eclipse.paho.client.mqttv3.MqttCallback, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, SmartInitializingSingleton, ApplicationContextAware, ApplicationEventPublisherAware, Lifecycle, Phased, SmartLifecycle, ExpressionCapable, MessageProducer, IntegrationPattern, MqttComponent<org.eclipse.paho.client.mqttv3.MqttConnectOptions>, MqttPahoComponent, NamedComponent, ManageableLifecycle, ManageableSmartLifecycle, TrackableComponent

public class MqttPahoMessageDrivenChannelAdapter extends AbstractMqttMessageDrivenChannelAdapter implements org.eclipse.paho.client.mqttv3.MqttCallback, MqttPahoComponent
Eclipse Paho Implementation. When consuming MqttIntegrationEvents published by this component use MqttPahoComponent adapter = event.getSourceAsType() to get a reference, allowing you to obtain the bean name and MqttConnectOptions. This technique allows consumption of events from both inbound and outbound endpoints in the same event listener.
Since:
4.0
Author:
Gary Russell, Artem Bilan
  • Field Details

    • DISCONNECT_COMPLETION_TIMEOUT

      public static final long DISCONNECT_COMPLETION_TIMEOUT
      The default disconnect completion timeout in milliseconds.
      See Also:
  • Constructor Details

    • MqttPahoMessageDrivenChannelAdapter

      public MqttPahoMessageDrivenChannelAdapter(String url, String clientId, MqttPahoClientFactory clientFactory, String... topic)
      Use this constructor for a single url (although it may be overridden if the server URI(s) are provided by the MqttConnectOptions.getServerURIs() provided by the MqttPahoClientFactory).
      Parameters:
      url - the URL.
      clientId - The client id.
      clientFactory - The client factory.
      topic - The topic(s).
    • MqttPahoMessageDrivenChannelAdapter

      public MqttPahoMessageDrivenChannelAdapter(String clientId, MqttPahoClientFactory clientFactory, String... topic)
      Use this constructor if the server URI(s) are provided by the MqttConnectOptions.getServerURIs() provided by the MqttPahoClientFactory.
      Parameters:
      clientId - The client id.
      clientFactory - The client factory.
      topic - The topic(s).
      Since:
      4.1
    • MqttPahoMessageDrivenChannelAdapter

      public MqttPahoMessageDrivenChannelAdapter(String url, String clientId, String... topic)
      Use this constructor when you don't need additional MqttConnectOptions.
      Parameters:
      url - The URL.
      clientId - The client id.
      topic - The topic(s).
  • Method Details

    • setDisconnectCompletionTimeout

      public void setDisconnectCompletionTimeout(long completionTimeout)
      Set the completion timeout when disconnecting. Not settable using the namespace. Default 5000L milliseconds.
      Parameters:
      completionTimeout - The timeout.
      Since:
      5.1.10
    • setRecoveryInterval

      public void setRecoveryInterval(int recoveryInterval)
      The time (ms) to wait between reconnection attempts. Default 10000.
      Parameters:
      recoveryInterval - the interval.
      Since:
      4.2.2
    • getConnectionInfo

      public org.eclipse.paho.client.mqttv3.MqttConnectOptions getConnectionInfo()
      Description copied from interface: MqttComponent
      Return information about the connection.
      Specified by:
      getConnectionInfo in interface MqttComponent<org.eclipse.paho.client.mqttv3.MqttConnectOptions>
      Specified by:
      getConnectionInfo in interface MqttPahoComponent
      Returns:
      the information.
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class MessageProducerSupport
    • doStart

      protected void doStart()
      Description copied from class: MessageProducerSupport
      Take no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.
      Overrides:
      doStart in class MessageProducerSupport
    • doStop

      protected void doStop()
      Description copied from class: MessageProducerSupport
      Take no action by default. Subclasses may override this if they need lifecycle-managed behavior.
      Overrides:
      doStop in class MessageProducerSupport
    • addTopic

      public void addTopic(String topic, int qos)
      Description copied from class: AbstractMqttMessageDrivenChannelAdapter
      Add a topic to the subscribed list.
      Overrides:
      addTopic in class AbstractMqttMessageDrivenChannelAdapter
      Parameters:
      topic - The topic.
      qos - The qos.
    • removeTopic

      public void removeTopic(String... topic)
      Description copied from class: AbstractMqttMessageDrivenChannelAdapter
      Remove a topic (or topics) from the subscribed list.
      Overrides:
      removeTopic in class AbstractMqttMessageDrivenChannelAdapter
      Parameters:
      topic - The topic.
    • connectionLost

      public void connectionLost(Throwable cause)
      Specified by:
      connectionLost in interface org.eclipse.paho.client.mqttv3.MqttCallback
    • messageArrived

      public void messageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
      Specified by:
      messageArrived in interface org.eclipse.paho.client.mqttv3.MqttCallback
    • deliveryComplete

      public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token)
      Specified by:
      deliveryComplete in interface org.eclipse.paho.client.mqttv3.MqttCallback