Conversation
8ed760f to
6d981ef
Compare
|
here is the PR in my own repo for outbound v3/v5 adapters (mjd507#1). |
|
@cppwfs , this is no rush: for the next milestone or so. Thanks |
Related to: spring-projects#3102 To avoid constructor explosion, only `MqttClientBuilder` or `MqttClientManager` are designed as input params for building the adapters. The `MqttClientManager` requires a `MqttClientBuilder` as well. When build the underlying `MqttClient`, the config from the input `MqttClientBuilder` will be cloned to avoid global side effect. Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
cppwfs
left a comment
There was a problem hiding this comment.
Thank you so much for this great contribution! We look forward to your updates for the requested changes!
…into hivemq-mqtt Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com> # Conflicts: # gradle/libs.versions.toml
… the mqttClient. - catch a RuntimeException around `sendMessage`, in case failure happens on Netty I/O thread. - change root package from `org` to `com` - use `Mosquitto` for faster startup time. - add `this` prefix for member fields usage - docs and tests improvement Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
- remove try-catch around `sendMessage` Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
cppwfs
left a comment
There was a problem hiding this comment.
This is great. Just a couple more changes.
Thank you for your work on this!
…ient - rename HiveMQ related classes, variables to MQTT. Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
cppwfs
left a comment
There was a problem hiding this comment.
Wow great work. A couple of things I noticed. Please verify and or resolve. Thank you!
|
|
||
| @Override | ||
| public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { | ||
| Assert.notNull(applicationEventPublisher, "'applicationEventPublisher' cannot be null"); |
There was a problem hiding this comment.
We don't need to check for null. Nullify handles this for us.
| .useMqttVersion3() | ||
| .willPublish(mqttClientConfig.getWillPublish().orElse(null)) | ||
| .simpleAuth(mqttClientConfig.getSimpleAuth().orElse(null)) | ||
| .addConnectedListener(Mqtt3ClientManager.this) |
There was a problem hiding this comment.
We can use just this. instead of Mqtt3clientManager.this
| // so have to skip appending this in the new built disconnectedListener list | ||
| .automaticReconnect(inputConfig.getAutomaticReconnect().orElse(null)); | ||
|
|
||
| if (!CollectionUtils.isEmpty(inputConfig.getConnectedListeners())) { |
| builder = builder.addConnectedListener(connectedListener); | ||
| } | ||
| } | ||
| if (!CollectionUtils.isEmpty(inputConfig.getDisconnectedListeners())) { |
| .withExposedPorts(HIVEMQ_PORT) | ||
| .withExposedPorts(MQTT_PORT) | ||
| .withNetwork(ToxiproxyContainerTest.NETWORK) | ||
| .withNetworkAliases("hivemq-broker"); |
There was a problem hiding this comment.
Oops missed this one , we can use mqtt-broker.
| protected AbstractMqttClientManager(B mqttClientBuilder) { | ||
| this.mqttClientBuilder = mqttClientBuilder; | ||
| @SuppressWarnings("this-escape") | ||
| protected AbstractMqttClientManager(C mqttClientConfig) { |
There was a problem hiding this comment.
AbstractMqttClientManager.java:69-78 — the constructor calls the overridable buildClient(...), and both implementations pass this as a MqttClientConnectedListener (Mqtt3ClientManager.java:51, Mqtt5ClientManager.java:216). This publishes a partially constructed object: this is registered as a live callback and subclass fields are still uninitialized.
A potential fix is to have each leaf construct the client and pass it up via super(config, client) so no overridable call happens during construction.
renechoi
left a comment
There was a problem hiding this comment.
Built the branch locally (Mosquitto 2.1.2).
-
No
doStop(). Afteradapter.stop()(isRunning()false) a publish still reached the output channel: the HiveMQ callback stays subscribed. Both Paho adapters stop delivery (MqttPahoMessageDrivenChannelAdapter:220,Mqttv5PahoMessageDrivenChannelAdapter:319) and manage a resubscribe flag;isSubscribedneeds the same. -
The four
com.hivemq.client.internalimports have public equivalents on 1.4.0:Mqtt3Connect/Mqtt5Connect/Mqtt5Disconnect.builder().build()equal the internalDEFAULTs, andMqtt5Subscription.DEFAULT_*match.
Related to: #3102
To avoid constructor explosion, only
MqttClientBuilderorMqttClientManagerare designed as input params for building the adapters.The
MqttClientManagerrequires aMqttClientBuilderas well.When build the underlying
MqttClient, the config from the inputMqttClientBuilderwill be cloned to avoid global side effect.