Abacn commented on code in PR #39180:
URL: https://github.com/apache/beam/pull/39180#discussion_r3507290837
##########
sdks/java/io/mqtt/src/main/java/org/apache/beam/sdk/io/mqtt/MqttIO.java:
##########
@@ -603,11 +619,20 @@ public boolean start() throws IOException {
Read<T> spec = source.spec;
try {
client = spec.connectionConfiguration().createClient();
- LOG.debug("Reader client ID is {}", client.getClientId());
- checkpointPreparer.clientId = client.getClientId().toString();
- connection = createConnection(client);
- connection.subscribe(
- new Topic[] {new Topic(spec.connectionConfiguration().getTopic(),
QoS.AT_LEAST_ONCE)});
+ this.clientId =
client.getConfig().getClientIdentifier().map(Object::toString).orElse("");
+ LOG.debug("Reader client ID is {}", clientId);
+ checkpointPreparer.clientId = clientId;
+ client.connect();
+
+ // Subscribe and get the publishes stream with manual acks enabled
+ publishes = client.publishes(MqttGlobalPublishFilter.ALL, true);
+
+ client
+ .subscribeWith()
+ .topicFilter(spec.connectionConfiguration().getTopic())
+ .qos(MqttQos.AT_LEAST_ONCE)
+ .send();
Review Comment:
As long as `close()` is called it's not leaking. No need to handle exception
in every occurrence of client access
--
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]