Guest User

Untitled

a guest
Dec 11th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. @Slf4j
  2. public class FluxPublishTest {
  3.  
  4. @Test
  5. public void test() {
  6.  
  7. Scheduler scheduler = Schedulers.immediate();
  8.  
  9. Flux.range(1, 5)
  10. .map(n -> Mono.just(n).publishOn(scheduler).map(k -> process(k))
  11. .thenEmpty(m -> log.info("Job Done")).subscribe()).subscribe();
  12. }
  13.  
  14. public Mono<Object> process(Object n) {
  15. log.info("Processing : {}", n);
  16. return Mono.empty();
  17. }
  18. }
  19.  
  20. 15:21:22.753 [main] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
  21. 15:21:22.906 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Processing : 1
  22. 15:21:22.909 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Job Done
  23. 15:21:22.910 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Processing : 2
  24. 15:21:22.910 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Job Done
  25. 15:21:22.910 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Processing : 3
  26. 15:21:22.910 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Job Done
  27. 15:21:22.912 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Processing : 4
  28. 15:21:22.912 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Job Done
  29. 15:21:22.912 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Processing : 5
  30. 15:21:22.912 [main] INFO com.capitalone.fs.marketingone.FluxPublishTest - Job Done
Add Comment
Please, Sign In to add comment