-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
[mqtt] Changed MQTT client from Paho to HiveMQ #1125
Conversation
Points to discuss:
|
Thanks for pushing this forwards. 👍 I think adding a netty feature is a good addition. Personally I would go for an additional constructor if the only configuration option is v3/v5. To future proof choosing between many options using a builder might be another option. But it's probably overkill if there's just this one configuration option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for this PR.
I've added a few inline comments.
...ansport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java
Outdated
Show resolved
Hide resolved
...ansport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java
Outdated
Show resolved
Hide resolved
...ansport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java
Show resolved
Hide resolved
...ansport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java
Outdated
Show resolved
Hide resolved
|
||
// use defaults when not provided by caller | ||
qos = qos == null ? this.qos : qos; | ||
retain = retain == null ? this.retain : retain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are using deprecated class fields in this non-deprecated method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No way to remin backward compatible otherwise. When we remove the retain-setter/getter, we can default that to false (what is the default now, if not explicitely set otherwise).
@@ -890,7 +888,7 @@ public void publish(String topic, byte[] payload, MqttActionCallback listener) { | |||
* exceptionally on an error or with a result of false if no broker connection is established. | |||
*/ | |||
public CompletableFuture<Boolean> publish(String topic, byte[] payload) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark this deprecated maybe? Implicitly it uses deprecated class fields ("retain", "qos").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll use the default (QoS 0 and retain false) after the getter/setter is removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are discussing deprecation: What is the use-case for subscribeRaw
and unsubscribeRaw
? If there are no subscribers, why should the connection subscribe to a topic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it had to do keep alive subscriptions. But not sure anymore, I should have documented those methods better. Did you encounter any usages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in openhab2-addons and not in openhab-core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecating or better removing should be fine then. I also do not see any benefit in keeping this API.
} | ||
return f; | ||
CompletableFuture<Boolean> future = new CompletableFuture<>(); | ||
client.publish(topic, payload, retain, qos).whenComplete((m, t) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't you use the clients future directly as return value? Maybe add the (unnecessary) boolean argument to the future to make it compatible?
This conversion stuff happening here right now is probably more inefficient than carrying a useless boolean in the type signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clients return different futures: CompletableFuture<Mqtt3Publish>
and CompletableFuture<Mqtt5Publish>
.
...port.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/internal/ClientCallback.java
Outdated
Show resolved
Hide resolved
...qtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/sslcontext/SSLContextProvider.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far, one last inline comment from my side
...ansport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java
Outdated
Show resolved
Hide resolved
@openhab/core-maintainers If we postpone this again, we‘ll be too close to the next milestone to merge it. And I would feel uncomfortable to add this to a release without having it tested in a milestone before. |
I'm ok with merging, but I would like to see @davidgraeff's final approval on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks you for the work. I am afraid I cannot say much about the topic itself but I added some code style comments. Feel free to resolve them.
...ansport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java
Outdated
Show resolved
Hide resolved
...ansport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java
Outdated
Show resolved
Hide resolved
if (t == null) { | ||
future.complete(true); | ||
} else { | ||
logger.info("Error subscribing to topic {}", topic, t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an error, why not log an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the wording and upgraded to warn. error is too much IMO, this does not affect the funtion of the other topics or the connection.
...ansport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java
Outdated
Show resolved
Hide resolved
...qtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/ssl/CustomTrustManagerFactory.java
Outdated
Show resolved
Hide resolved
case 2: | ||
return MqttQos.EXACTLY_ONCE; | ||
default: | ||
throw new IllegalArgumentException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to use a specific message for this exception?
...in/java/org/eclipse/smarthome/io/transport/mqtt/internal/client/Mqtt5AsyncClientWrapper.java
Outdated
Show resolved
Hide resolved
...in/java/org/eclipse/smarthome/io/transport/mqtt/internal/client/Mqtt5AsyncClientWrapper.java
Outdated
Show resolved
Hide resolved
...in/java/org/eclipse/smarthome/io/transport/mqtt/internal/client/Mqtt3AsyncClientWrapper.java
Outdated
Show resolved
Hide resolved
...in/java/org/eclipse/smarthome/io/transport/mqtt/internal/client/Mqtt3AsyncClientWrapper.java
Outdated
Show resolved
Hide resolved
Please note that https://github.com/openhab/openhab2-addons/pull/6245 needs to be merged to keep the tests in addons running. |
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de> GitOrigin-RevId: 07d10db
Supersedes #929.
Signed-off-by: Jan N. Klug jan.n.klug@rub.de