Subscribe to supplier flux in background thread

Stops application from blowing up if there are messages available
on startup and the broker is not there. There are still errors
(failed messages), but it doesn't stop the app from starting.

Maybe should be optional to fail fast?
This commit is contained in:
Dave Syer
2017-09-22 09:45:37 +01:00
parent af8b6e253e
commit 280fa5794c

View File

@@ -26,6 +26,7 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
/**
* @author Mark Fisher
@@ -41,7 +42,7 @@ public class SupplierInvokingMessageProducer<T> extends MessageProducerSupport {
@Override
protected void doStart() {
supplier().subscribe(m -> this.sendMessage(m));
supplier().subscribeOn(Schedulers.elastic()).subscribe(m -> this.sendMessage(m));
}
private Flux<Message<?>> supplier() {