/** * From IMessagingClient */ @Override public ListenableFuture<RapidResponse> sendMessageBestEffort(final Endpoint remote, final RapidRequest msg) { Objects.requireNonNull(msg); try { return backgroundExecutor.submit(() -> { final Supplier<ListenableFuture<RapidResponse>> call = () -> { final MembershipServiceFutureStub stub; stub = getFutureStub(remote).withDeadlineAfter(getTimeoutForMessageMs(msg), TimeUnit.MILLISECONDS); return stub.sendRequest(msg); }; final Runnable onCallFailure = () -> channelMap.invalidate(remote); return Retries.callWithRetries(call, remote, 0, onCallFailure, backgroundExecutor); }).get(); } catch (final InterruptedException | ExecutionException e) { Thread.currentThread().interrupt(); return Futures.immediateFailedFuture(e); } }
/** * From IMessagingClient */ @Override public ListenableFuture<RapidResponse> sendMessage(final Endpoint remote, final RapidRequest msg) { Objects.requireNonNull(remote); Objects.requireNonNull(msg); final Supplier<ListenableFuture<RapidResponse>> call = () -> { final MembershipServiceFutureStub stub = getFutureStub(remote) .withDeadlineAfter(getTimeoutForMessageMs(msg), TimeUnit.MILLISECONDS); return stub.sendRequest(msg); }; final Runnable onCallFailure = () -> channelMap.invalidate(remote); return Retries.callWithRetries(call, remote, settings.getGrpcDefaultRetries(), onCallFailure, backgroundExecutor); }