Skip to content

Conversation

scmi-c8y
Copy link
Contributor

@scmi-c8y scmi-c8y commented Aug 18, 2025

Opening this up for the full review now that we have a complete first draft plus work-in-progress sample code in Cumulocity-IoT/cumulocity-examples#158.

The relevant part of the preview is: https://cumulocity-iot-c8y-docs-build-pr-3642.surge.sh/device-integration/mqtt-service/#pulsar-client

Some open questions that we should answer collectively, and make sure the implementation agrees with the doc:

  • Should a missing client property should be treated the same as empty, or as a bad message to be ignored?
  • I documented using the "routing key" (which is used to calculate the topic partition and the key-shared partition if the ordering key is not set) rather than the "ordering key" (which is only used by key-shared subscriptions) because 1) then we only have to set one key, 2) the routing key can be set from a String (at least in the Java API) and 3) IMHO this is less confusing for the user. However if people disagree with that we can change the doc/example to use the ordering key.
  • Should we have a stronger statement about not supporting clients that don't set the key correctly?

@scmi-c8y scmi-c8y self-assigned this Aug 18, 2025
Copy link
Contributor

Preview available here

Copy link
Contributor

@rohitjoshi-c8y rohitjoshi-c8y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few early comments for now, as requested — I will take a closer look later.

Microservices and external applications can connect to the {{< product-c8y-iot >}} Messaging Service to receive messages from devices connected to the MQTT Service, and send messages to those devices.
The Messaging Service is a modified deployment of Apache Pulsar, and your applications will use the Pulsar client protocol directly to connect to it.

### Connecting to the Messaging Service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: A quick prerequisites section helps perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good thought. What would you have as pre-requisites?

weight: 30
layout: redirect
title: Connecting microservices and applications
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Could a simple architecture diagram showing how these components fit together help? Maybe too much to ask for now, and perhaps we can come back to it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about updating the diagrams we already have in the intro section of the doc. I guess I might be inspired to copy parts of those into the later sections and add more detail.

<p>

* Code snippet showing how to publish

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue/suggestion: It might be useful to add a section on error handling so readers know how to deal with common error scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's another good idea. Not sure what I would put in it exactly... probably I should try to remember all the ways I mess up in writing some example code.

<p>

* Code snippet showing how to shut down cleanly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throught: Would it be helpful to include a short “common pitfalls” list (e.g., forgetting to acknowledge messages -> backlog quota filled)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is really what this "best practices" section was supposed to be, and I think I already mentioned the consequences of not acknowledging a few lines up from here. It should be clearer when all these bullets are turned into actual prose.

Co-authored-by: Rohit Joshi <89976252+rohitjoshi-c8y@users.noreply.github.com>
@scmi-c8y scmi-c8y marked this pull request as ready for review September 9, 2025 09:40
@scmi-c8y scmi-c8y requested a review from BeateRixen as a code owner September 9, 2025 09:40
@scmi-c8y
Copy link
Contributor Author

scmi-c8y commented Sep 9, 2025

@rohitjoshi-c8y it would be good to get your thoughts on the 4 comments of your that I left open. I might have covered these in the re-written text already, but if not I probably need some more details of what you were looking for.

To do this, your microservice or external application will connect to the {{< product-c8y-iot >}} Messaging Service, a modified deployment of [Apache Pulsar](https://pulsar.apache.org/), and use the Pulsar protocol to publish and consume MQTT messages.
The diagram below shows the important interfaces and data flows used when interacting with the MQTT Service through Pulsar.

<p align="center" width="100%">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think this wonderful diagram should be moved/condensed/changed+reused for Overview / Architecture - the diagram there is very legacy-oriented. Maybe now, or maybe in a later ticket, not sure.

The diagram below shows the important interfaces and data flows used when interacting with the MQTT Service through Pulsar.

<p align="center" width="100%">
<img width="80%" src="/images/mqtt-service/mqtt-service-pulsar-connections.svg" alt="MQTT Service Pulsar connections">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Wonderful diagram, just the right amount of fiction to help a user model it in their mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Now that we're exposing a reliable messaging system more explicitly, used to communicate with another (potentially) reliable messaging service, I wonder if there's scope for confusion. As a user I might think that when I publish a message to Pulsar, when I get an acknowledgement from it it means that the MQTT device has acknowledged it. A similar delusion in the other direction perhaps.

Somewhere we might want to disillusion them of this, and be clear about it being decoupled. And another consequence of decoupling is a lack of errors - publishing to a non-existent MQTT topic or device via Pulsar will just complete and drop the message into a blackhole.

The message will only be published to a client that is connected at the time the MQTT Service processes the published message.

In order to enforce device-level isolation, the message will be published **only** to the specific MQTT client identified by the `clientID` message property, provided that client has an active subscription to the relevant MQTT topic.
If the `clientID` property is empty, the message will be sent to **all** connected MQTT clients with active subscriptions to the MQTT topic.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or at least that's what https://cumulocity.atlassian.net/browse/MTM-64283 says.

Suggested change
If the `clientID` property is empty, the message will be sent to **all** connected MQTT clients with active subscriptions to the MQTT topic.
If the `clientID` property is missing, the message will be sent to **all** connected MQTT clients with active subscriptions to the MQTT topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants