我具有许多MessageProducer
实现的现有接口链。
interface MessageProducer {
void produce(MessageQueue messageQueue);
}
interface MessageQueue {
void submit(Message message);
}
如何在界面更改尽可能少的情况下使其适应reactor Flux
?像
class FluxMessageQueueAdapter implements MessageQueue {
private Flux<Message> flux = ...
public void submit(Message message) {
flux.next(message);
}
}
答案 0 :(得分:0)
似乎一个解决方案可能是
MessageProducer producer =
Flux.push((emitter) -> {
FluxMessageQueueAdapter adapter = new FluxMessagerQueueAdapter(emitter);
producer.produce(adapter);
emitter.complete();
})
.subscribe(System.out::println);