use of io.scalecube.net.Address in project ignite-3 by apache.
the class ScaleCubeDirectMarshallerTransport method requestResponse.
/**
* {@inheritDoc}
*/
@Override
public Mono<Message> requestResponse(Address address, Message request) {
return Mono.create(sink -> {
Objects.requireNonNull(request, "request must be not null");
Objects.requireNonNull(request.correlationId(), "correlationId must be not null");
Disposable receive = listen().filter(resp -> resp.correlationId() != null).filter(resp -> resp.correlationId().equals(request.correlationId())).take(1).subscribe(sink::success, sink::error, sink::success);
Disposable send = send(address, request).subscribe(null, ex -> {
receive.dispose();
sink.error(ex);
});
sink.onDispose(Disposables.composite(send, receive));
});
}
Aggregations