Skip to content

Commit 4506223

Browse files
committed
samewith completablefuture
1 parent bc0d2d3 commit 4506223

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

sb3-mt-samples/src/main/java/com/ashfaq/example/bulkoperation/PlanService.java

+17
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,21 @@ public void processBatch(List<PlanRequest> planRequests) {
213213
// If there are still tasks left (let's say 10), they will be placed in the queue.
214214
// If the queue is full (100 tasks), and additional tasks come in, the calling thread will start processing them (because of CallerRunsPolicy).
215215

216+
217+
//same with completable future and executor service config as we can Chaining of Dependent Tasks, Non-Blocking Callback Handling ......
218+
// public CompletableFuture<Void> processBatchAsync(List<PlanRequest> planRequests) {
219+
// return CompletableFuture.allOf(
220+
// planRequests.stream()
221+
// .map(planRequest -> CompletableFuture.supplyAsync(() -> processRowAction(planRequest), executorService)
222+
// .thenAccept(success -> {
223+
// if (success) {
224+
// // Handle success logic here, such as logging or status update
225+
// } else {
226+
// // Handle failure logic here
227+
// }
228+
// }))
229+
// .toArray(CompletableFuture[]::new)
230+
// );
231+
// }
232+
216233
}

0 commit comments

Comments
 (0)