We're using Reactive Spring Data Repository with Spring WebFlux, My understanding for SubscribeOn says it decides on which ThreadPool the operators before SubscribeOn will execute in the flux, while PublishOn decides the actual ThreadPool on which the subscription will execute. However in the below code even with PublishOn and SubscribeOn, the code isn't getting executed on Main Thread rather it's falling back to Cluster-nio-worker-1.
System.out.println("Current Thread :- "+Thread.currentThread().getName()); //Current Thread :- main
personRepository.findAll().log()
.map(document -> mapDocumentToSomethingElse(document)) //Current thread cluster-nio-worker-1
.subscribeOn(Schedulers.immediate())
.publishOn(Schedulers.immediate())
.subscribe(trackingevent -> System.out.println("Got Item "+item +" inside thread "+Thread.currentThread()), //Thread[cluster-nio-worker-1,5,main]
excp -> excp.printStackTrace(),
() -> System.out.println("Completed processing Thread:- "+Thread.currentThread().getName())); //cluster-nio-worker-1
Also what does Thread[cluster-nio-worker-1,5,main] mean? Why are these method calls not using the main thread for execution.