@Override public void run() { try { suspended.put(ar); LOGGER.log(DEBUG, "GET <{0}> context {1} scheduled for resume.", new Object[] {messageId, ar.toString()}); } catch (InterruptedException ex) { LOGGER.log(Level.SEVERE, "Waiting for a message pick-up interrupted. Cancelling context" + ar.toString(), ex); ar.cancel(); // close the open connection } } });
@Override public void run() { try { final String message = messages.take(); LOGGER.log(DEBUG, "Resuming GET <{0}> context {1} with a message {2} on thread {3}.", new Object[]{messageId, ar.toString(), message, Thread.currentThread().getName()}); ar.resume(message); } catch (InterruptedException ex) { LOGGER.log(Level.SEVERE, "Waiting for a message pick-up interrupted. Cancelling context" + ar.toString(), ex); ar.cancel(); // close the open connection } } });
protected void removeDuplicates() { for (FetchAndLockRequest newRequest : newRequests) { // remove any request from pendingRequests with the same worker id Iterator<FetchAndLockRequest> iterator = pendingRequests.iterator(); while (iterator.hasNext()) { FetchAndLockRequest pendingRequest = iterator.next(); if (pendingRequest.getDto().getWorkerId().equals(newRequest.getDto().getWorkerId())) { AsyncResponse asyncResponse = pendingRequest.getAsyncResponse(); asyncResponse.cancel(); iterator.remove(); } } } }
@Override public void run() { try { delegate.run(); } catch(Exception e) { asyncResponse.cancel(); throw new RuntimeException(e); } } }
@Override public void onError(Throwable t) { if (t instanceof CancellationException) { ar.cancel(); } else { ar.resume(t); } }
@Override public void handleTimeout(AsyncResponse asyncResponse) { asyncResponse.cancel(10); }
@Override public void onError(Throwable t) { if (t instanceof CancellationException) { ar.cancel(); } else { ar.resume(t); } }
@Override public void onError(Throwable t) { closed = true; Optional<Response> response = ErrorHandler .handleUnaryError(t, httpHeaderClientInterceptor.getHttpResponseHeaders()); if (response.isPresent()) { asyncResponse.resume(response.get()); } else { asyncResponse.cancel(); } }