GH-9368: Adding MqttMessageDrivenChannelAdapter at runtime

Fixes: #9368

* fixing MessageDrivenAdapters

1) exposing isConnection() in ClientManager
2) implementing isConnection() in Mqttv3ClientManager and Mqttv5ClientManager
3) Modifining OnInit() in AbstractMqttMessageDrivenChannelAdapter

* Adding test to ClientManagerBackToBackTests

Adding tests for addition of MessageDrivenAdapters at runtime.

1) Adding config classes Mqttv3ConfigWithStartedManager, Mqttv5ConfigWithStartedManager.
2) Adding test for config classes above.

* Fixing code style

* Adding required changes

* `ClientManager` - @since 6.4 comment to `isConnecttion()`
* `Mqttv3ClientManager`, `Mqttv5ClientManager` - adding local variable and lock logic
* `AbstractMqttMessageDrivenChannelAdapter` - changed `connectCompete()` to false

* adding runtime ClientManger tests

* `testV3ClientManagerRuntime` and `testV5ClientManagerRuntime` adding MessageDrivenAdaptes at runtime using `IntegrationFlowContext`

* Adding Documentation for MqttPahoMessageDrivenChannelAdapter and Mqttv5PahoMessageDrivenChannelAdapter

* fixing code style

* adding required chnages

* `ClientManager`, `Mqttv3ClientManager`, `Mqttv5ClientManager`, `AbstractMqttMessageDrivenChannelAdapter` - renamig `isConnection()` to `isConnected()`
* fixing docs `mqtt.adoc` and `whats-new.adoc`
* `ClientManagerBackToBackTests` adding factory interface `MessageDrivenChannelAdapterFactory` to create adapters

* removing started tests
This commit is contained in:
Ricore72
2024-08-19 17:48:02 +02:00
committed by GitHub
parent e90fd686a0
commit d1146e5f17
7 changed files with 190 additions and 6 deletions

View File

@@ -382,9 +382,9 @@ public class MqttJavaApplication {
.run(args);
}
@Bean
public IntegrationFlow mqttOutboundFlow() {
return f -> f.handle(new MqttPahoMessageHandler("tcp://host1:1883", "someMqttClient"));
@Bean
public IntegrationFlow mqttOutboundFlow() {
return f -> f.handle(new MqttPahoMessageHandler("tcp://host1:1883", "someMqttClient"));
}
}
@@ -548,3 +548,19 @@ public IntegrationFlow mqttOutFlow(
return f -> f.handle(new Mqttv5PahoMessageHandler(clientManager));
}
----
NOTE: Starting with version 6.4, multiple instances of `MqttPahoMessageDrivenChannelAdapter` and `Mqttv5PahoMessageDrivenChannelAdapter` can now be added at runtime using corresponding `ClientManager` through `IntegrationFlowContext`
[source,java]
----
private void addAddRuntimeAdapter(IntegrationFlowContext flowContext, Mqttv5ClientManager clientManager,
String topic, MessageChannel channel) {
flowContext
.registration(
IntegrationFlow
.from(new Mqttv5PahoMessageDrivenChannelAdapter(clientManager, topic))
.channel(channel)
.get())
.register();
}
----

View File

@@ -61,8 +61,16 @@ See xref:redis.adoc[Redis Support] for more information.
The `ControlBusFactoryBean` (and respective `<int-groovy:control-bus>` XML tag) has been deprecated (for removal) in favor of new introduced `ControlBusFactoryBean` based on a new model implemented in the `ControlBusCommandRegistry`.
See xref:control-bus.adoc[Control Bus] for more information.
[[x6.4-sftp-changes]]
=== SFTP Support Changes
The `DefaultSftpSessionFactory` now exposes a `Consumer<SshClient>` configurer property to further customize an internal `SshClient`.
See xref:sftp/session-factory.adoc[SFTP Session Factory] for more information.
See xref:sftp/session-factory.adoc[SFTP Session Factory] for more information.
[[x6.4-mqtt-support-changes]]
=== MQTT Support Changes
Multiple instances of `MqttPahoMessageDrivenChannelAdapter` and `Mqttv5PahoMessageDrivenChannelAdapter` can now be added at runtime using corresponding `ClientManager` through `IntegrationFlowContext`
See xref:mqtt.adoc[MQTT Support] for more information.