Class InboundAdapter

All Implemented Interfaces:
AutoCloseable, org.eclipse.paho.mqttv5.client.MqttCallback, org.springframework.boot.health.contributor.HealthContributor, org.springframework.boot.health.contributor.HealthIndicator

public class InboundAdapter extends MqttDataSourceAdapter<InboundDataSource>
  • Constructor Details

    • InboundAdapter

      public InboundAdapter(InboundDataSource dataSource, tools.jackson.databind.ObjectMapper mapper, MqttConfiguration mqttConfiguration)
      Creates the adapter for the inbound data source. It connects to the specified MQTT broker and expects that the EP publishes its messages on the specified topic.
      Parameters:
      dataSource - The entity of the data source.
  • Method Details

    • connectComplete

      public void connectComplete(boolean reconnect, String serverURI)
      Description copied from class: MqttDataSourceAdapter
      Called when the connection to the broker has been established and will then subscribe to the topic specified in mqttConfig.
      Specified by:
      connectComplete in interface org.eclipse.paho.mqttv5.client.MqttCallback
      Overrides:
      connectComplete in class MqttDataSourceAdapter<InboundDataSource>
      Parameters:
      reconnect - If true, the connection was the result of automatic reconnect.
      serverURI - The server URI that the connection was made to.
    • messageArrived

      public void messageArrived(String topic, org.eclipse.paho.mqttv5.common.MqttMessage message)
      MQTT callback function that is called when a new message from the broker is received. Will store the message in plaintext format in the database, as this datasource is not designed to parse the messages.
      Parameters:
      topic - Name of the topic, the message was published to.
      message - The actual message.
    • deliveryComplete

      public void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token)
      Description copied from class: MqttDataSourceAdapter
      Will always throw UnsupportedOperationException, as this datasource is not designed to publish data.
      Specified by:
      deliveryComplete in interface org.eclipse.paho.mqttv5.client.MqttCallback
      Overrides:
      deliveryComplete in class MqttDataSourceAdapter<InboundDataSource>
      Parameters:
      token - The delivery token associated with the message.
    • inboundRecordFlux

      public reactor.core.publisher.Flux<InboundRecord> inboundRecordFlux()
    • createConnectOptions

      protected org.eclipse.paho.mqttv5.client.MqttConnectionOptions createConnectOptions()
      Overrides:
      createConnectOptions in class MqttDataSourceAdapter<InboundDataSource>