Files
spring-functions-catalog/consumer/spring-mqtt-consumer

= MQTT Consumer

A consumer that allows you to send messages using the MQTT protocol.

== Beans for injection

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

`Consumer<Message<?>> mqttConsumer`

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

== Configuration Options

All configuration properties are prefixed with `mqtt.consumer`.

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

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

== 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/consumer/mqtt/MqttConsumerTests.java[test suite] for the various ways, this consumer is used.

== Other usage

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