rvballada commented on code in PR #22932:
URL: https://github.com/apache/beam/pull/22932#discussion_r996957968


##########
sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/JmsIO.java:
##########
@@ -582,29 +594,83 @@ public long getTotalBacklogBytes() {
     }
 
     @Override
-    public void close() throws IOException {
+    public void close() {
+      doClose();
+    }
+
+    @SuppressWarnings("FutureReturnValueIgnored")
+    private void doClose() {
+
       try {
-        if (consumer != null) {
-          consumer.close();
-          consumer = null;
+        closeAutoscaler();
+        closeConsumer();
+        ScheduledExecutorService executorService = 
Executors.newSingleThreadScheduledExecutor();

Review Comment:
   How do we get the executor service from ExecutorOptions? As far as I can 
see, PipelineOptions should be then a reader field, but how do we get the 
ExecutorService from PipelineOptions?



##########
sdks/java/io/jms/src/test/java/org/apache/beam/sdk/io/jms/JmsIOTest.java:
##########
@@ -555,6 +556,101 @@ public void testCustomAutoscaler() throws IOException {
     verify(autoScaler, times(1)).stop();
   }
 
+  @Test
+  public void testCloseWithTimeout()
+      throws IOException, NoSuchFieldException, IllegalAccessException {
+
+    int closeTimeout = 2000;
+    JmsIO.Read spec =
+        JmsIO.read()
+            .withConnectionFactory(connectionFactory)
+            .withUsername(USERNAME)
+            .withPassword(PASSWORD)
+            .withQueue(QUEUE)
+            .withCloseTimeout(closeTimeout);
+
+    JmsIO.UnboundedJmsSource source = new JmsIO.UnboundedJmsSource(spec);
+    JmsIO.UnboundedJmsReader reader = source.createReader(null, null);
+
+    reader.start();
+    reader.close();

Review Comment:
   How do we get the executor service from ExecutorOptions? As far as I can 
see, PipelineOptions should be then a reader field, but how do we get the 
ExecutorService from PipelineOptions?



-- 
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]

Reply via email to