github-actions[bot] commented on code in PR #41503:
URL: https://github.com/apache/beam/pull/41503#discussion_r4644968353
##########
sdks/java/io/mqtt/src/main/java/org/apache/beam/sdk/io/mqtt/MqttIO.java:
##########
@@ -534,20 +723,26 @@ public UnboundedMqttSource(Read<T> spec) {
@SuppressWarnings("unchecked")
public UnboundedReader<T> createReader(
PipelineOptions options, @Nullable MqttCheckpointMark checkpointMark) {
+ if (checkpointMark != null) {
+ // A runner resumes from a checkpoint only once it is committed, so
its messages can be
+ // acknowledged if the reader that took it lives in this JVM.
+ checkpointMark.finalizeCheckpoint();
+ }
final UnboundedMqttReader<T> unboundedMqttReader;
MqttCheckpointMark.Preparer preparer =
checkpointMark == null
? new MqttCheckpointMark.Preparer()
- : new MqttCheckpointMark.Preparer(checkpointMark);
+ : new MqttCheckpointMark.Preparer(checkpointMark.clientId);
Review Comment:
**🟡 Medium**: `createReader` initializes `Preparer` with
`checkpointMark.clientId`, and `ConnectionConfiguration.createClient()` always
generates a new random UUID client ID when connecting. However, if
`UnboundedMqttReader` is used in a test or with a client whose config has no
identifier (`client.getConfig().getClientIdentifier()` is empty), `start()`
sets `this.clientId = ""` and overwrites `checkpointPreparer.clientId` with
`""` (line 842). Furthermore, `ConnectionConfiguration.createClient()` never
reuses `checkpointMark.clientId` when reconnecting a resumed reader, which may
prevent the MQTT broker from resuming the previous client's session.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]