@Override public int getRetryCount() { return this.context.getRetryCount(); }
private Acknowledgement doSendMsgs(final List<MessageExt> msgs, RetryContext context) { List<Acknowledgement> acknowledgements = new ArrayList<>(); msgs.forEach(msg -> { String retryInfo = context == null ? "" : "retryCount-" + String.valueOf(context.getRetryCount()) + "|"; logger.debug(retryInfo + "consuming msg:\n" + msg); logger.debug(retryInfo + "message body:\n" + new String(msg.getBody())); Acknowledgement acknowledgement = new Acknowledgement(); Message<byte[]> toChannel = convertMessagingFromRocketMQMsg(msg, acknowledgement); acknowledgements.add(acknowledgement); RocketMQInboundChannelAdapter.this.sendMessage(toChannel); }); return acknowledgements.get(0); }
public BatchRetryContext(RetryContext parent, Collection<RetryContext> contexts) { super(parent); this.contexts = contexts; int count = 0; for (RetryContext context : contexts) { int retryCount = context.getRetryCount(); if (retryCount > count) { count = retryCount; registerThrowable(context.getLastThrowable()); } } }
/** * Test for retryable operation based on the status. * * @see org.springframework.retry.RetryPolicy#canRetry(org.springframework.retry.RetryContext) * * @return true if the last exception was retryable and the number of * attempts so far is less than the limit. */ @Override public boolean canRetry(RetryContext context) { Throwable t = context.getLastThrowable(); return (t == null || retryForException(t)) && context.getRetryCount() < maxAttempts; }
private void registerContext(RetryContext context, RetryState state) { if (state != null) { Object key = state.getKey(); if (key != null) { if (context.getRetryCount() > 1 && !this.retryContextCache.containsKey(key)) { throw new RetryException( "Inconsistent state for failed item key: cache key has changed. " + "Consider whether equals() or hashCode() for the key might be inconsistent, " + "or if you need to supply a better key"); } this.retryContextCache.put(key, context); } } }
@Override public String[] doWithRetry(RetryContext context) throws Exception { assertEquals(count, context.getRetryCount()); if (count++ == 0) { throw new RecoverableException("Recoverable"); } return new String[] { "a", "b" }; } };
this.logger.debug("Retry: count=" + context.getRetryCount()); this.logger .debug("Abort retry because interrupted: count=" + context.getRetryCount()); "Checking for rethrow: count=" + context.getRetryCount()); if (this.logger.isDebugEnabled()) { this.logger.debug("Rethrow in retry for policy: count=" + context.getRetryCount()); "Retry failed last attempt: count=" + context.getRetryCount());
@Override public T doWithRetry(RetryContext context) throws Exception { if (context.getRetryCount() > 0) { logger.warn("Retry of Redis Operation. Retry Count = " + context.getRetryCount()); } return RedisRetryTemplate.super.execute(action, exposeConnection, pipeline); }
@Override public T doWithRetry(RetryContext context) throws Exception { if (context.getRetryCount() > 0) { logger.warn("Retry of Redis Operation. Retry Count = " + context.getRetryCount()); } return RedisRetryTemplate.super.execute(action, exposeConnection, pipeline); }
@Override public T doWithRetry(RetryContext context) throws Exception { if (context.getRetryCount() > 0) { logger.warn("Retry of Redis Operation. Retry Count = " + context.getRetryCount()); } return RedisRetryTemplate.super.execute(action, exposeConnection, pipeline); }
public void setRetryContext( RetryContext retryContext ) { this.retryContext = retryContext; log.info( "Now trying. Current count: " + (retryContext.getRetryCount() + 1) ); }
@Override public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) { Object mappingName = context.getAttribute(MAPPING_NAME_RETRY_ATTRIBUTE); if (mappingName != null) { if (throwable != null) { log.error("All {} attempts to forward HTTP request using '{}' mapping has failed. {}", context.getRetryCount(), mappingName, retrieveErrorMessage(throwable)); } else { log.debug("Attempt {} to forward HTTP request using '{}' mapping has succeeded", context.getRetryCount() + 1, mappingName); } } }
@Override public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) { Object mappingName = context.getAttribute(MAPPING_NAME_RETRY_ATTRIBUTE); if (mappingName != null) { log.debug("Attempt {} to forward HTTP request using '{}' mapping has failed. {}", context.getRetryCount() + 1, mappingName, retrieveErrorMessage(throwable)); } }
public BatchRetryContext(RetryContext parent, Collection<RetryContext> contexts) { super(parent); this.contexts = contexts; int count = 0; for (RetryContext context : contexts) { int retryCount = context.getRetryCount(); if (retryCount > count) { count = retryCount; registerThrowable(context.getLastThrowable()); } } }
public BatchRetryContext(RetryContext parent, Collection<RetryContext> contexts) { super(parent); this.contexts = contexts; int count = 0; for (RetryContext context : contexts) { int retryCount = context.getRetryCount(); if (retryCount > count) { count = retryCount; registerThrowable(context.getLastThrowable()); } } }
public BatchRetryContext(RetryContext parent, Collection<RetryContext> contexts) { super(parent); this.contexts = contexts; int count = 0; for (RetryContext context : contexts) { int retryCount = context.getRetryCount(); if (retryCount > count) { count = retryCount; registerThrowable(context.getLastThrowable()); } } }
/** * Test for retryable operation based on the status. * * @see org.springframework.retry.RetryPolicy#canRetry(org.springframework.retry.RetryContext) * * @return true if the last exception was retryable and the number of * attempts so far is less than the limit. */ @Override public boolean canRetry(RetryContext context) { Throwable t = context.getLastThrowable(); return (t == null || retryForException(t)) && context.getRetryCount() < maxAttempts; }
@Override public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable cause) { // Log only attempt and error. DefaultContainerErrorHandler will log details. Integer attempt = context == null ? null : (context.getRetryCount() + 1); cause = exceptionTransformer.transform(cause); String message = RabbitMQMessageCode.AMQP_ERROR_RETRY_E.getMessageText(attempt, cause.getMessage()); LOGGER.error(message); } }
@Override public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable cause) { // Log only attempt and error. DefaultContainerErrorHandler will log details. Integer attempt = context == null ? null : (context.getRetryCount() + 1); cause = exceptionTransformer.transform(cause); String message = RabbitMQMessageCode.AMQP_ERROR_RETRY_E.getMessageText(attempt, cause.getMessage()); LOGGER.error(message); } }
@Override public boolean canRetry(RetryContext context) { Throwable t = context.getLastThrowable(); return (t == null || classify(t)) && context.getRetryCount() < getMaxAttempts(); } }