0
votes

So I have a simple method

Flux<Task> getTaskToProcess();

I would like my system to stream entites continously. Right now I achive it in old fashion like

while(!Thread.currentThread().isInterrupted()){
    getTaskToProcess().flatMap(....)
}

I am pretty sure it's not the best way by reactive approach. How to achieve continous emitter in project reactor ?

1
any task you put on a mono/flux will emit as soon as the task is done resolving.Toerktumlare
yes I do understand I was looking for something like inifinite scheduler - so while(true) loop i reactive mannerClyde Barrow

1 Answers

0
votes

Try Flux#create or Flux# generate:

Flux<Task> tasks = Flux.create(sink -> {
  while(!Thread.currentThread().isInterrupted()) {
     sink.next(something);
  }
  sink.complete();
})
.subscribeOn(Schedulers.newSingle("stdin publisher"))