use of com.hedera.mirror.monitor.subscribe.SubscribeResponse in project hedera-mirror-node by hashgraph.
the class RestSubscriber method clientSubscribe.
private Flux<SubscribeResponse> clientSubscribe(RestSubscription subscription) {
RestSubscriberProperties properties = subscription.getProperties();
RetryBackoffSpec retrySpec = Retry.backoff(properties.getRetry().getMaxAttempts(), properties.getRetry().getMinBackoff()).maxBackoff(properties.getRetry().getMaxBackoff()).filter(this::shouldRetry).doBeforeRetry(r -> log.debug("Retry attempt #{} after failure: {}", r.totalRetries() + 1, r.failure().getMessage()));
return subscription.getSink().asFlux().publishOn(Schedulers.parallel()).doFinally(s -> subscription.onComplete()).doOnNext(publishResponse -> log.trace("Querying REST API: {}", publishResponse)).flatMap(publishResponse -> webClient.get().uri("/transactions/{transactionId}", toString(publishResponse.getTransactionId())).retrieve().bodyToMono(MirrorTransaction.class).name("rest").metrics().timeout(properties.getTimeout()).retryWhen(retrySpec).onErrorContinue((t, o) -> subscription.onError(t)).doOnNext(subscription::onNext).map(transaction -> toResponse(subscription, publishResponse, transaction))).take(properties.getLimit(), true).take(properties.getDuration());
}
Aggregations