@Override public Object doWithRetry(RetryContext context) throws Exception { context.setAttribute(RetryContext.NAME, label); try { return this.invocation.proceed(); } catch (Exception e) { throw e; } catch (Error e) { throw e; } catch (Throwable e) { throw new IllegalStateException(e); } } }
public Object doWithRetry(RetryContext context) throws Exception { context.setAttribute(RetryContext.NAME, label); /* * If we don't copy the invocation carefully it won't keep a reference to * the other interceptors in the chain. We don't have a choice here but to * specialise to ReflectiveMethodInvocation (but how often would another * implementation come along?). */ if (invocation instanceof ProxyMethodInvocation) { try { return ((ProxyMethodInvocation) invocation).invocableClone().proceed(); } catch (Exception e) { throw e; } catch (Error e) { throw e; } catch (Throwable e) { throw new IllegalStateException(e); } } else { throw new IllegalStateException( "MethodInvocation of the wrong type detected - this should not happen with Spring AOP, " + "so please raise an issue if you see this exception"); } }
/** * Clean up the cache if necessary and close the context provided (if the flag * indicates that processing was successful). * * @param retryPolicy the {@link RetryPolicy} * @param context the {@link RetryContext} * @param state the {@link RetryState} * @param succeeded whether the close succeeded */ protected void close(RetryPolicy retryPolicy, RetryContext context, RetryState state, boolean succeeded) { if (state != null) { if (succeeded) { if (!context.hasAttribute(GLOBAL_STATE)) { this.retryContextCache.remove(state.getKey()); } retryPolicy.close(context); context.setAttribute(RetryContext.CLOSED, true); } } else { retryPolicy.close(context); context.setAttribute(RetryContext.CLOSED, true); } }
private RetryContext doOpenInternal(RetryPolicy retryPolicy, RetryState state) { RetryContext context = retryPolicy.open(RetrySynchronizationManager.getContext()); if (state != null) { context.setAttribute(RetryContext.STATE_KEY, state.getKey()); } if (context.hasAttribute(GLOBAL_STATE)) { registerContext(context, state); } return context; }
context.setAttribute(RetryContext.EXHAUSTED, true); if (state != null && !context.hasAttribute(GLOBAL_STATE)) { this.retryContextCache.remove(state.getKey()); context.setAttribute(RetryContext.RECOVERED, true); return recovered;
backOffContext = backOffPolicy.start(context); if (backOffContext != null) { context.setAttribute("backOffContext", backOffContext);
@Override public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) { context.setAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY, messageHolder.get()); return true; }
@Override public void onMessage(final ConsumerRecord<K, V> record, final Acknowledgment acknowledgment, final Consumer<?, ?> consumer) { RetryState retryState = null; if (this.stateful) { retryState = new DefaultRetryState(record.topic() + "-" + record.partition() + "-" + record.offset()); } getRetryTemplate().execute(context -> { context.setAttribute(CONTEXT_RECORD, record); switch (RetryingMessageListenerAdapter.this.delegateType) { case ACKNOWLEDGING_CONSUMER_AWARE: context.setAttribute(CONTEXT_ACKNOWLEDGMENT, acknowledgment); context.setAttribute(CONTEXT_CONSUMER, consumer); RetryingMessageListenerAdapter.this.delegate.onMessage(record, acknowledgment, consumer); break; case ACKNOWLEDGING: context.setAttribute(CONTEXT_ACKNOWLEDGMENT, acknowledgment); RetryingMessageListenerAdapter.this.delegate.onMessage(record, acknowledgment); break; case CONSUMER_AWARE: context.setAttribute(CONTEXT_CONSUMER, consumer); RetryingMessageListenerAdapter.this.delegate.onMessage(record, consumer); break; case SIMPLE: RetryingMessageListenerAdapter.this.delegate.onMessage(record); } return null; }, getRecoveryCallback(), retryState); }
public void updateRetryContext( String stepKey, String message, MetadataVersion version ) { retryContext.setAttribute( stepKey, message ); if ( version != null ) { retryContext.setAttribute( MetadataSyncJob.VERSION_KEY, version ); } }
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) { context.setAttribute("message", messageHolder.get()); return true; }
@Override public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) { context.setAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY, messageHolder.get()); return true; }
@Override public Object doWithRetry(RetryContext context) throws Exception { context.setAttribute(RetryContext.NAME, label); try { return this.invocation.proceed(); } catch (Exception e) { throw e; } catch (Error e) { throw e; } catch (Throwable e) { throw new IllegalStateException(e); } } }
public Object doWithRetry(RetryContext context) throws Exception { context.setAttribute(RetryContext.NAME, label); /* * If we don't copy the invocation carefully it won't keep a reference to * the other interceptors in the chain. We don't have a choice here but to * specialise to ReflectiveMethodInvocation (but how often would another * implementation come along?). */ if (invocation instanceof ProxyMethodInvocation) { try { return ((ProxyMethodInvocation) invocation).invocableClone().proceed(); } catch (Exception e) { throw e; } catch (Error e) { throw e; } catch (Throwable e) { throw new IllegalStateException(e); } } else { throw new IllegalStateException( "MethodInvocation of the wrong type detected - this should not happen with Spring AOP, " + "so please raise an issue if you see this exception"); } }
private void setupImportReport( ImportReport importReport ) { Status status = importReport.getStatus(); if ( Status.ERROR.equals( status ) ) { StringBuilder report = new StringBuilder(); List<ErrorReport> errorReports = importReport.getErrorReports(); for ( ErrorReport errorReport : errorReports ) { if ( errorReport != null ) { report.append( errorReport.toString() + "\n" ); } } retryContext.setAttribute( MetadataSyncJob.METADATA_SYNC_REPORT, report.toString() ); } } }
/** * Clean up the cache if necessary and close the context provided (if the flag * indicates that processing was successful). * * @param retryPolicy the {@link RetryPolicy} * @param context the {@link RetryContext} * @param state the {@link RetryState} * @param succeeded whether the close succeeded */ protected void close(RetryPolicy retryPolicy, RetryContext context, RetryState state, boolean succeeded) { if (state != null) { if (succeeded) { if (!context.hasAttribute(GLOBAL_STATE)) { this.retryContextCache.remove(state.getKey()); } retryPolicy.close(context); context.setAttribute(RetryContext.CLOSED, true); } } else { retryPolicy.close(context); context.setAttribute(RetryContext.CLOSED, true); } }
private RetryContext doOpenInternal(RetryPolicy retryPolicy, RetryState state) { RetryContext context = retryPolicy.open(RetrySynchronizationManager.getContext()); if (state != null) { context.setAttribute(RetryContext.STATE_KEY, state.getKey()); } if (context.hasAttribute(GLOBAL_STATE)) { registerContext(context, state); } return context; }
context.setAttribute(RetryContext.EXHAUSTED, true); if (state != null && !context.hasAttribute(GLOBAL_STATE)) { this.retryContextCache.remove(state.getKey()); context.setAttribute(RetryContext.RECOVERED, true); return recovered;
}, ctx -> { if (this.recoveryCallback != null) { ctx.setAttribute(SendRetryContextAccessor.MESSAGE, messageToSend); ctx.setAttribute(SendRetryContextAccessor.ADDRESS, replyTo); this.recoveryCallback.recover(ctx); return null;
}, ctx -> { if (this.recoveryCallback != null) { ctx.setAttribute(SendRetryContextAccessor.MESSAGE, messageToSend); ctx.setAttribute(SendRetryContextAccessor.ADDRESS, replyTo); this.recoveryCallback.recover(ctx); return null;
public ResponseEntity<byte[]> forwardHttpRequest(RequestData data, String traceId, RetryContext context, MappingProperties mapping) { forwardedRequestInterceptor.intercept(data); ForwardDestination destination = resolveForwardDestination(data.getUri(), mapping); prepareForwardedRequestHeaders(data, destination); traceInterceptor.onForwardStart(traceId, destination.getMappingName(), data.getMethod(), destination.getUri().toString(), data.getBody(), data.getHeaders()); context.setAttribute(MAPPING_NAME_RETRY_ATTRIBUTE, destination.getMappingName()); RequestEntity<byte[]> request = new RequestEntity<>(data.getBody(), data.getHeaders(), data.getMethod(), destination.getUri()); ResponseData response = sendRequest(traceId, request, mapping, destination.getMappingMetricsName(), data); log.debug("Forwarding: {} {} -> {} {}", data.getMethod(), data.getUri(), destination.getUri(), response.getStatus().value()); traceInterceptor.onForwardComplete(traceId, response.getStatus(), response.getBody(), response.getHeaders()); receivedResponseInterceptor.intercept(response); prepareForwardedResponseHeaders(response); return status(response.getStatus()) .headers(response.getHeaders()) .body(response.getBody()); }