magyari-adam commented on code in PR #4164:
URL: https://github.com/apache/fineract/pull/4164#discussion_r1840862445


##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/jobs/SendAsynchronousEventsTasklet.java:
##########
@@ -104,14 +111,40 @@ private void markEventsAsSent(List<Long> eventIds) {
         // Partitioning dataset to avoid exception: PreparedStatement can have 
at most 65,535 parameters
         final int partitionSize = 
fineractProperties.getEvents().getExternal().getPartitionSize();
         List<List<Long>> partitions = Lists.partition(eventIds, partitionSize);
+        final ThreadPoolTaskExecutor executor = getThreadPoolTaskExecutor();
+        final FineractContext context = ThreadLocalContextUtil.getContext();
+        List<Future<?>> tasks = new ArrayList<>();
         partitions //
                 .forEach(partitionedEventIds -> {
-                    measure(() -> {
-                        repository.markEventsSent(partitionedEventIds, sentAt);
-                    }, timeTaken -> {
-                        log.debug("Took {}ms to update {} events", 
timeTaken.toMillis(), partitionedEventIds.size());
-                    });
+                    tasks.add(executor.submit(() -> {
+                        measure(() -> {
+                            ThreadLocalContextUtil.init(context);
+                            repository.markEventsSent(partitionedEventIds, 
sentAt);
+                        }, timeTaken -> {
+                            log.debug("Took {}ms to update {} events", 
timeTaken.toMillis(), partitionedEventIds.size());
+                        });
+                    }));
                 });
+        tasks.forEach(task -> {
+            try {
+                task.get();
+            } catch (InterruptedException | ExecutionException e) {
+                throw new RuntimeException(e);
+            }
+        });
+    }
+
+    @NotNull
+    private ThreadPoolTaskExecutor getThreadPoolTaskExecutor() {

Review Comment:
   You're right, moved it to config.



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