I have my threadPoolExecutor method defined as such in my config class
@Bean
@Qualifier("abc")
public ExecutorService methodName() {
return new ThreadPoolExecutor(5, 15,
10, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
new ThreadFactoryBuilder()
.setNameFormat("export-client-thread-%d")
.build());
}
In my springboot application, inside one of service classes I have this method that fetches for some information via an API call, this is how the method is defined
@Qualifier("abc")
ExecutorService executor;
ThirdPartyApi api;
public Foo fetchData(){
api.getData(param1, param2, executor).join();
}
Inside the api class I use some async methods to fetch data defined as
MooAsync mooasync;
@Async
public CompletableFuture<Foo> getFoo(Param1, Param2, ExecutorService executor){
return CompletableFuture.supplyAsync(() -> {
try{
//do something
foo = ();
} catch(){}
moo = mooasync.getMoo(foo.something, foo.something, executor).join();
foo = helperMethod(moo, foo);
return foo;
}, executor);
}
This is how MooAsync class is defined
@Async
public CompletableFuture<Moo> getMoo(Param1, Param2, ExecutorService executor){
return CompletableFuture.supplyAsync(() -> {
try{
//do something
moo = ();
} catch(){}
return moo;
}, executor);
}
The problem I face is in the Api class only the foo method call returns something but the moo method call is never being made and so I'm not able to see the result of moo when I'm trying to do some aggregation of data in my helper method with the result of moo and foo
Although if I remove the executor in the MooAsync class and NOT pass it down to that class, everything works.
Can I not pass an executor from a supplyAsync Completable future (1) to another method that also uses supplyAsync Completable future (2), inside the first one?