Camel Spring Boot

Vert.x MQTT

Send and receive messages with an MQTT 3.1.1 or MQTT 5 broker, using the Vert.x MQTT client.

What’s inside

Please refer to the above links for usage and configuration details.

Maven coordinates

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-vertx-mqtt-starter</artifactId>
</dependency>

Spring Boot Auto-Configuration

The starter supports 33 options, which are listed below.

Name Description Default Type

camel.component.vertx-mqtt.ack-timeout

How long a message of quality of service 1 or 2 waits for its acknowledgement, in seconds. The exchange fails when the time is up. 0 or less waits without a limit.

30

Integer

camel.component.vertx-mqtt.automatic-reconnect

Whether the client connects again when the connection is lost, and keeps trying in the background when the first connection fails. If false, a failed first connection fails the start of the consumer or producer, and a lost connection is not connected again.

true

Boolean

camel.component.vertx-mqtt.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.vertx-mqtt.bridge-error-handler

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

Boolean

camel.component.vertx-mqtt.broker-url

The URL of the broker: tcp://host:port or mqtt://host:port for a plain connection, ssl://host:port or mqtts://host:port for TLS. Without a port, 1883 is used for a plain connection and 8883 for TLS. The URL must not hold user information, a path or a query: the username and password options carry the credentials.

tcp://localhost:1883

String

camel.component.vertx-mqtt.clean-start

Whether the broker discards the session of the client when it connects: the Clean Start flag of MQTT 5, the Clean Session flag of MQTT 3.1.1. If false, the broker keeps the subscriptions and the queued messages of the client, and the consumer does not unsubscribe when it stops. With MQTT 5 the session also needs a sessionExpiryInterval above 0 to outlive the connection.

true

Boolean

camel.component.vertx-mqtt.client-id

The client identifier of the connection. If not set, a random UUID is used, and a new one every time the connection starts again, so a session that the broker keeps (cleanStart false) needs a clientId. The broker allows one connection per client identifier, so two endpoints must not share one.

String

camel.component.vertx-mqtt.configuration

The configuration that every endpoint of the component starts from. An endpoint works on its own copy, so its options do not change the component. The option is a org.apache.camel.component.vertx.mqtt.VertxMqttConfiguration type.

VertxMqttConfiguration

camel.component.vertx-mqtt.connect-timeout

How long to wait for a connection to the broker, in milliseconds. It bounds every connection attempt, and how long the producer waits for the connection before the exchange fails. The option is a long type.

30000

Long

camel.component.vertx-mqtt.enabled

Whether to enable auto configuration of the vertx-mqtt component. This is enabled by default.

Boolean

camel.component.vertx-mqtt.keep-alive-interval

The keep alive interval in seconds. 0 switches keep alive off.

30

Integer

camel.component.vertx-mqtt.lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean

camel.component.vertx-mqtt.manual-acks-enabled

Whether the consumer acknowledges a message of quality of service 1 or 2 only once its exchange completed successfully, instead of as soon as it arrives. When the exchange of a message of quality of service 1 fails, the consumer reconnects so that the broker delivers it again, which needs automaticReconnect and a session that outlives the connection (cleanStart false, and with MQTT 5 a sessionExpiryInterval above 0). Otherwise the failed message is acknowledged and not delivered again.

false

Boolean

camel.component.vertx-mqtt.max-inflight-queue

The most messages of quality of service 1 and 2 that the producer has sent without an acknowledgement from the broker. The exchange of a message beyond it fails at once.

10

Integer

camel.component.vertx-mqtt.max-message-size

The largest message in bytes the client receives, the protocol maximum by default. Every message is read into memory as a whole, so lower it for a broker whose publishers are not trusted.

268435455

Integer

camel.component.vertx-mqtt.max-pending-messages

The most received messages whose exchanges have not completed. When it is reached, the consumer stops reading from the connection until half of them completed, which holds back the broker for every quality of service.

1000

Integer

camel.component.vertx-mqtt.max-reconnect-delay

The longest delay between two attempts to reconnect, in milliseconds, before the random part of up to a fifth is added. The option is a long type.

60000

Long

camel.component.vertx-mqtt.mqtt-version

The version of the MQTT protocol that the client speaks with the broker. With MQTT_3_1_1, the sessionExpiryInterval and receiveMaximum options and the MQTT 5 headers are not used.

mqtt-5-0

VertxMqttVersion

camel.component.vertx-mqtt.password

The password to authenticate with.

String

camel.component.vertx-mqtt.qos

The quality of service: 0 (at most once), 1 (at least once) or 2 (exactly once). The producer publishes with it, and the CamelVertxMqttOverrideQos header replaces it. The consumer subscribes with it, as the highest quality of service that the broker delivers messages with.

1

Integer

camel.component.vertx-mqtt.receive-maximum

MQTT 5 only. The most messages of quality of service 1 and 2 that the broker sends to the client without an acknowledgement. 0 does not send the Receive Maximum property, and MQTT 5 then allows 65535.

0

Integer

camel.component.vertx-mqtt.reconnect-delay

The delay before the first attempt to reconnect, in milliseconds. Every further attempt doubles the delay, up to maxReconnectDelay, and adds up to a fifth of it at random. A successful connection starts again from this delay. The option is a long type.

1000

Long

camel.component.vertx-mqtt.retained

Whether the producer publishes messages as retained, so that the broker keeps the last one of the topic for subscribers that arrive later. The CamelVertxMqttOverrideRetained header replaces this option.

false

Boolean

camel.component.vertx-mqtt.session-expiry-interval

MQTT 5 only. How long the broker keeps the session after the connection closed, in seconds. 0 ends it with the connection.

0

Long

camel.component.vertx-mqtt.ssl-context-parameters

The TLS configuration of a connection to an ssl:// or mqtts:// broker: key managers for a client certificate, trust managers, protocols and cipher suites. Without it the trust store of the JVM is used. The host name of the broker is always verified against its certificate: there is intentionally no option to switch the check off. The option is a org.apache.camel.support.jsse.SSLContextParameters type.

SSLContextParameters

camel.component.vertx-mqtt.use-global-ssl-context-parameters

Whether to use the global SSL context parameters of the Camel context for an endpoint that sets none.

false

Boolean

camel.component.vertx-mqtt.username

The user name to authenticate with.

String

camel.component.vertx-mqtt.vertx

The Vert.x instance that the connections run on. If not set, the single Vert.x instance in the registry is used, or else the component creates a Vert.x instance of its own and closes it when the component stops. The option is a io.vertx.core.Vertx type.

Vertx

camel.component.vertx-mqtt.vertx-options

The options of the Vert.x instance that the component creates when the vertx option is not set and the registry does not hold exactly one Vert.x instance. The option is a io.vertx.core.VertxOptions type.

VertxOptions

camel.component.vertx-mqtt.will-payload

The payload of the will message, sent as UTF-8 bytes. Only used when willTopic is set.

String

camel.component.vertx-mqtt.will-qos

The quality of service of the will message: 0, 1 or 2. Only used when willTopic is set.

0

Integer

camel.component.vertx-mqtt.will-retained

Whether the broker publishes the will message as retained. Only used when willTopic is set.

false

Boolean

camel.component.vertx-mqtt.will-topic

The topic of the will message the broker publishes when the client goes away without disconnecting.

String