Skip to content

Customizing the underlying MQTT client

You can customize the underlying MQTT Client configuration by producing an instance of io.smallrye.reactive.messaging.mqtt.session.MqttClientSessionOptions:

@Produces
@Identifier("my-options")
public MqttClientSessionOptions getOptions() {
    // You can use the produced options to configure the TLS connection
    PemKeyCertOptions keycert = new PemKeyCertOptions()
            .addCertPath("./tls/tls.crt")
            .addKeyPath("./tls/tls.key");
    PemTrustOptions trust = new PemTrustOptions().addCertPath("./tlc/ca.crt");

    return new MqttClientSessionOptions()
            .setSsl(true)
            .setPemKeyCertOptions(keycert)
            .setPemTrustOptions(trust)
            .setHostnameVerificationAlgorithm("")
            .setConnectTimeout(30000)
            .setReconnectInterval(5000);
}

This instance is retrieved and used to configure the client used by the connector. You need to indicate the name of the client using the client-options-name attribute:

mp.messaging.incoming.prices.client-options-name=my-options