Skip to content

Adding Mqttv5PahoMessageDrivenChannelAdapter to running Mqttv5ClientManager #9368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ricore72 opened this issue Aug 7, 2024 · 2 comments · Fixed by #9382
Closed

Adding Mqttv5PahoMessageDrivenChannelAdapter to running Mqttv5ClientManager #9368

Ricore72 opened this issue Aug 7, 2024 · 2 comments · Fixed by #9382

Comments

@Ricore72
Copy link
Contributor

Ricore72 commented Aug 7, 2024

version 6.3.1

Description
I want to add multiple instances of Mqttv5PahoMessageDrivenChannelAdapter (on demand, when application is running) using already running client in Mqttv5ClientManager as constructor parameter. When I try, it does not work.
Cause seams to be MqttCallback:: connectComplete ,which sets the readyToSubscribeOnStart property.
That obviously cant trigger because client is already connected.

To Reproduce

  1. Create an instance of Mqttv5ClientManager
  2. Start clientManager
  3. create an instance of Mqttv5PahoMessageDrivenChannelAdapter with clientManager
  4. register adapter in IntegrationFlow using IntegrationFlowContext
  5. Try to send messages to it

Possible Fix
https://github.com/Ricore72/spring-integration
The fix does not work completely.

It only works if Handlers and adapters using same clientManager have the same Qos.

Note
I am not sure if this is the proper way to do this. This is my first issue to public project. So sorry if it is incorrect in any way.

@Ricore72 Ricore72 added status: waiting-for-triage The issue need to be evaluated and its future decided type: bug labels Aug 7, 2024
@artembilan
Copy link
Member

It looks like the ClientManager should expose an isConnection() API.
The problem is that your ClientManager has been started and connected.
So, all those dynamically added channel adapters at runtime just lose their connectComplete() callback.
Therefore in the AbstractMqttMessageDrivenChannelAdapter.onInit() we should check for the mentioned ClientManager.isConnection() and set readyToSubscribeOnStart = true.
So, when this dynamic channel adapter is started it will understand that it is already OK to subscribe.

Feel free to play with that and contribute back: https://github.com/spring-projects/spring-integration/blob/main/CONTRIBUTING.adoc

Thank you!

@artembilan artembilan added status: waiting-for-reporter Needs a feedback from the reporter and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels Aug 7, 2024
@artembilan artembilan added this to the 6.4.0-M2 milestone Aug 14, 2024
@artembilan
Copy link
Member

I changing this to Enhancement since we never advertised that such a scenario is supposed to work.
So, new feature for new version.
Will review your PR shortly.
Thanks

Ricore72 added a commit to Ricore72/spring-integration that referenced this issue Aug 16, 2024
Ricore72 added a commit to Ricore72/spring-integration that referenced this issue Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants