-
Notifications
You must be signed in to change notification settings - Fork 70
feat: single connection to either mqtt service or core mqtt #3862
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
feat: single connection to either mqtt service or core mqtt #3862
Conversation
crates/core/tedge/src/bridge/c8y.rs
Outdated
| format!(r#"devicecontrol/notifications in 1 {topic_prefix}/ """#), | ||
| format!(r#"error in 1 {topic_prefix}/ """#), | ||
| // Custom outgoing topics to MQTT service | ||
| format!(r#"# out 1 {topic_prefix}/custom/out/ """#), |
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.
Used the subtopic: c8y/custom instead of c8y/mqtt based on the differentiation between built-in topics and custom topics.
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 don't see custom as clearer. I would be good to find a term stressing that the point is to triage messages to the MQTT service and not C8Y 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.
The c8y docs do use the mqtt term in the pulsar pulsar names, for instance
mqtt/from-devicemqtt/to-device
Using the same topics (with the additional c8y/ prefix) might be ok, though it is a little on the long side.
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.
Using the same topics (with the additional c8y/ prefix) might be ok, though it is a little on the long side.
That mqtt namespace makes sense from a Pulsar perspective as it receives inputs from multiple input channels. But using the same over an MQTT connection just felt redundant. That's why I changed it to custom.
Initially I was considering the c8y/mqtt-svc prefix, which explicitly highlights the "mqtt service" aspect. But decided against it considering the future where MQTT service is the one and only MQTT endpoint, in which case mqtt-svc would also be redundant. So, I thought of focussing on the functional differentiation between built-in topics vs user-provided/custom topics.
I don't see custom as clearer. I would be good to find a term stressing that the point is to triage messages to the MQTT service and not C8Y Core.
Ideally we need a name that highlights the functional difference in the future, but also makes the distinction between core mqtt and mqtt service endpoints clearer during this transition period. The discussed options, none ideal in all senses, are:
c8y/customc8y/mqtt-servicec8y/mqtt
If we can't come up with that ideal topic name, let's just vote and pick one between these 3.
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.
My preference would be c8y/mqtt
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.
Resolved by 61db72b
Robot Results
|
6807e74 to
05691cf
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
| let mqtt_svc_host = format!("{}:{}", mqtt_host.host(), MQTT_SVC_TLS_PORT); | ||
| mqtt_host = HostPort::<MQTT_TLS_PORT>::try_from(mqtt_svc_host) | ||
| .map_err(TEdgeConfigError::from)?; |
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.
This feels like a very brute-force approach to changing the port, where we generate a completely new string, then parse it. Can we not add a method such as HostPort::set_port to handle this case more cleanly? It might also make the code obvious enough we don't need such a large comment explaining what we're doing here
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.
Resolved by 61db72b
2c599d0 to
19909b5
Compare
tests/RobotFramework/tests/tedge_connect/tedge_connet_mqtt_service.robot
Show resolved
Hide resolved
didier-wenzek
left a comment
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 will be happy to approved once addressed the small test issue.
tests/RobotFramework/tests/tedge_connect/tedge_connet_mqtt_service.robot
Show resolved
Hide resolved
Connecting to Cumulocity now establishes a single MQTT connection either to the the core MQTT endpoint or the MQTT service, but not both. Connecting to MQTT service requires SmartREST proxy to be enabled on it, so that messaging over SmartREST and JSON over MQTT still works.
19909b5 to
e772f1c
Compare
didier-wenzek
left a comment
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.
Approved
Proposed changes
When
c8y.mqtt_service.enabledis set totrue, just connect to MQTT service endpoint on port 9883 instead of establishing two connections, one to core mqtt and another one to mqtt service. This feature can only be tested against a tenant with the SmartREST proxy feature of MQTT service enabled, so that the same connection can interact with the device over SmartREST or JSON over MQTT.Types of changes
Paste Link to the issue
#3858
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments