zhangshenghang commented on code in PR #9961:
URL: https://github.com/apache/seatunnel/pull/9961#discussion_r2442765123


##########
seatunnel-connectors-v2/connector-milvus/src/main/java/org/apache/seatunnel/connectors/seatunnel/milvus/sink/MilvusSinkWriter.java:
##########
@@ -41,13 +47,29 @@ public class MilvusSinkWriter
     private final MilvusBufferBatchWriter batchWriter;
     private ReadonlyConfig config;
 
+    private final ScheduledExecutorService scheduler;
+
+    private final ReentrantLock lock = new ReentrantLock();
+
+    private final AtomicReference<Exception> exception = new 
AtomicReference<>();
+
     public MilvusSinkWriter(
             Context context,
             CatalogTable catalogTable,
             ReadonlyConfig config,
             List<MilvusSinkState> milvusSinkStates) {
         this.batchWriter = new MilvusBufferBatchWriter(catalogTable, config);
         this.config = config;
+        int batchInterval = config.get(MilvusSinkOptions.BATCH_INTERVAL);
+        this.scheduler = batchInterval > 0 ? 
Executors.newSingleThreadScheduledExecutor() : null;
+        if (scheduler != null) {
+            log.info("create Milvus sink writer with batch interval: {}", 
batchInterval);
+            scheduler.scheduleAtFixedRate(
+                    new BatchWriterFlushRunnable(batchWriter),
+                    0,
+                    batchInterval,
+                    TimeUnit.MILLISECONDS);
+        }

Review Comment:
   > @zhangshenghang Do you mean to periodically flush data through the 
`prepareCommit()` triggered by checkpoint.interval in STREAMING mode?
   
   Yes, you can refer to other connectors.



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