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


##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/jobs/SendAsynchronousEventsTasklet.java:
##########
@@ -104,16 +109,34 @@ 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();
         partitions //
                 .forEach(partitionedEventIds -> {
-                    measure(() -> {
-                        repository.markEventsSent(partitionedEventIds, sentAt);
-                    }, timeTaken -> {
-                        log.debug("Took {}ms to update {} events", 
timeTaken.toMillis(), partitionedEventIds.size());
+                    executor.execute(() -> {
+                        measure(() -> {
+                            ThreadLocalContextUtil.init(context);
+                            repository.markEventsSent(partitionedEventIds, 
sentAt);
+                        }, timeTaken -> {
+                            log.debug("Took {}ms to update {} events", 
timeTaken.toMillis(), partitionedEventIds.size());
+                        });
                     });
                 });
     }
 
+    @Nonnull
+    private ThreadPoolTaskExecutor getThreadPoolTaskExecutor() {

Review Comment:
   Couldn't move it to the tasklet config as it would create a circular 
dependency between them, moved it to it's own 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