You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to #3685
* Add documentation for a new MQTT shared client feature
Add an overview with reason for the feature as well as basic
capabilities listing. Give an example with Java DSL usage for several
adapters.
* Fill `whats-new.adoc` with MQTT changes
Add a reference to MQTT documentation with info about shared MQTT client
* Couple of code review changes
Copy file name to clipboardExpand all lines: src/reference/asciidoc/mqtt.adoc
+59-1Lines changed: 59 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -500,4 +500,62 @@ IMPORTANT: The `org.springframework.integration.mqtt.support.MqttMessageConverte
500
500
See more information in the `Mqttv5PahoMessageDrivenChannelAdapter` javadocs and its superclass.
501
501
502
502
IMPORTANT: It is recommended to have the `MqttConnectionOptions#setAutomaticReconnect(boolean)` set to true to let an internal `IMqttAsyncClient` instance to handle reconnects.
503
-
Otherwise, only the manual restart of `Mqttv5PahoMessageDrivenChannelAdapter` can handle reconnects, e.g. via `MqttConnectionFailedEvent` handling on disconnection.
503
+
Otherwise, only the manual restart of `Mqttv5PahoMessageDrivenChannelAdapter` can handle reconnects, e.g. via `MqttConnectionFailedEvent` handling on disconnection.
504
+
505
+
[[mqtt-shared-client]]
506
+
=== Shared MQTT Client Support
507
+
508
+
If a single MQTT ClientID is required for several integrations, multiple MQTT client instances cannot be used because MQTT brokers may have a limitation on a number of connections per ClientID (typically, a single connection is allowed).
509
+
For having a single client reused for different channel adapters, a `org.springframework.integration.mqtt.core.ClientManager` component may be used and passed to any channel adapter needed.
510
+
It will manage MQTT connection lifecycle and do automatic reconnects if needed.
511
+
Also, a custom connection options and `MqttClientPersistence` may be provided to the client manager just as currently it can be done for channel adapter components.
512
+
513
+
Note that both MQTT v5 and v3 channel adapters are supported.
514
+
515
+
The following Java DSL configuration sample demonstrates how to use this client manager in the integration flow:
516
+
517
+
====
518
+
[source,java]
519
+
----
520
+
@Bean
521
+
public ClientManager<IMqttAsyncClient, MqttConnectionOptions> clientManager() {
522
+
MqttConnectionOptions connectionOptions = new MqttConnectionOptions();
0 commit comments