= MQTT Supplier

This module provides an MQTT supplier that can be reused and composed in other applications.
The `Supplier` uses the `MqttPahoMessageDrivenChannelAdapter` from Spring Integration.
`mqttSupplier` is implemented as a `java.util.function.Supplier`.
This supplier gives you a reactive stream from MQTT sources. The supplier has a signature of `Supplier<Flux<Message<?>>>`.
Users have to subscribe to this `Flux` and then receive the data.

== Beans for injection

The `MqttSupplierConfiguration` auto-configuration provides the following bean:

`mqttSupplier`

You need to inject this as `Supplier<Flux<Message<?>>>`.

You can use `mqttSupplier` as a qualifier when injecting.

Once injected, you can use the `get` method of the `Supplier` to invoke it and then subscribe to the returned `Flux`.

== Configuration Options

All configuration properties are prefixed with `mqtt.supplier` and `mqtt`.

For more information on the various options available, please see link:src/main/java/org/springframework/cloud/fn/supplier/mqtt/MqttSupplierProperties.java[MqttSupplierProperties].

A `ComponentCustomizer<MqttPahoMessageDrivenChannelAdapter>` bean can be added in the target project to provide any custom options for the `MqttPahoMessageDrivenChannelAdapter` configuration used by the `mqttSupplier`.

== SSL Configuration

The MQTT Paho client can accept an SSL configuration via `MqttConnectOptions.setSSLProperties()`.
These properties are exposed on the `MqttProperties.sslProperties` map.
The keys for these SSL properties should be taken from the `org.eclipse.paho.client.mqttv3.internal.security.SSLSocketFactoryFactory` constants, which all start with the `com.ibm.ssl.` prefix.

== Tests

See this link:src/test/java/org/springframework/cloud/fn/supplier/mqtt/MqttSupplierTests.java[test suite] for the various ways, this supplier is used.
In addition to this, there is also link:../../common/mqtt-common/src/main/java/org/springframework/cloud/fn/common/mqtt/MqttProperties.java[this set of properties] to consider.

== Other usage

See this https://github.com/spring-cloud/stream-applications/blob/master/applications/source/mqtt-source/README.adoc[README] where this supplier is used to create a Spring Cloud Stream application where it makes an MQTT Source.
