@Override protected <T> T handleRetryExhausted(RecoveryCallback<T> recoveryCallback, RetryContext context, RetryState state) throws Throwable { BatchRetryState batchState = (BatchRetryState) state; BatchRetryContext batchContext = (BatchRetryContext) context; // Accumulate exceptions to be thrown so all the keys get a crack Throwable rethrowable = null; ExhaustedRetryException exhausted = null; Iterator<RetryContext> contextIterator = batchContext.contexts.iterator(); for (RetryState retryState : batchState.keys) { RetryContext nextContext = contextIterator.next(); try { super.handleRetryExhausted(null, nextContext, retryState); } catch (ExhaustedRetryException e) { exhausted = e; } catch (Throwable e) { rethrowable = e; } } if (recoveryCallback != null) { return recoveryCallback.recover(context); } if (exhausted != null) { throw exhausted; } throw rethrowable; }
@Override public Acknowledgement recover(RetryContext context) throws Exception { RocketMQInboundChannelAdapter.this.recoveryCallback .recover(context); if (ClassUtils.isAssignable(this.getClass(), MessageListenerConcurrently.class)) { return Acknowledgement .buildConcurrentlyInstance(); } else { return Acknowledgement.buildOrderlyInstance(); } } });
T recovered = recoveryCallback.recover(context); context.setAttribute(RetryContext.RECOVERED, true); return recovered;
@Override protected <T> T handleRetryExhausted(RecoveryCallback<T> recoveryCallback, RetryContext context, RetryState state) throws Throwable { BatchRetryState batchState = (BatchRetryState) state; BatchRetryContext batchContext = (BatchRetryContext) context; // Accumulate exceptions to be thrown so all the keys get a crack Throwable rethrowable = null; ExhaustedRetryException exhausted = null; Iterator<RetryContext> contextIterator = batchContext.contexts.iterator(); for (RetryState retryState : batchState.keys) { RetryContext nextContext = contextIterator.next(); try { super.handleRetryExhausted(null, nextContext, retryState); } catch (ExhaustedRetryException e) { exhausted = e; } catch (Throwable e) { rethrowable = e; } } if (recoveryCallback != null) { return recoveryCallback.recover(context); } if (exhausted != null) { throw exhausted; } throw rethrowable; }
@Override protected <T> T handleRetryExhausted(RecoveryCallback<T> recoveryCallback, RetryContext context, RetryState state) throws Throwable { BatchRetryState batchState = (BatchRetryState) state; BatchRetryContext batchContext = (BatchRetryContext) context; // Accumulate exceptions to be thrown so all the keys get a crack Throwable rethrowable = null; ExhaustedRetryException exhausted = null; Iterator<RetryContext> contextIterator = batchContext.contexts.iterator(); for (RetryState retryState : batchState.keys) { RetryContext nextContext = contextIterator.next(); try { super.handleRetryExhausted(null, nextContext, retryState); } catch (ExhaustedRetryException e) { exhausted = e; } catch (Throwable e) { rethrowable = e; } } if (recoveryCallback != null) { return recoveryCallback.recover(context); } if (exhausted != null) { throw exhausted; } throw rethrowable; }
@Override protected <T> T handleRetryExhausted(RecoveryCallback<T> recoveryCallback, RetryContext context, RetryState state) throws Throwable { BatchRetryState batchState = (BatchRetryState) state; BatchRetryContext batchContext = (BatchRetryContext) context; // Accumulate exceptions to be thrown so all the keys get a crack Throwable rethrowable = null; ExhaustedRetryException exhausted = null; Iterator<RetryContext> contextIterator = batchContext.contexts.iterator(); for (RetryState retryState : batchState.keys) { RetryContext nextContext = contextIterator.next(); try { super.handleRetryExhausted(null, nextContext, retryState); } catch (ExhaustedRetryException e) { exhausted = e; } catch (Throwable e) { rethrowable = e; } } if (recoveryCallback != null) { return recoveryCallback.recover(context); } if (exhausted != null) { throw exhausted; } throw rethrowable; }
public void setRecoveryCallback(RecoveryCallback<Object> recoveryCallback) { this.recoveryCallback = context -> { if (!shouldRequeue((MessagingException) context.getLastThrowable())) { return recoveryCallback.recover(context); } throw (MessagingException) context.getLastThrowable(); }; }
@Override public Acknowledgement recover(RetryContext context) throws Exception { RocketMQInboundChannelAdapter.this.recoveryCallback .recover(context); if (ClassUtils.isAssignable(this.getClass(), MessageListenerConcurrently.class)) { return Acknowledgement .buildConcurrentlyInstance(); } else { return Acknowledgement.buildOrderlyInstance(); } } });
T recovered = recoveryCallback.recover(context); context.setAttribute(RetryContext.RECOVERED, true); return recovered;
ctx.setAttribute(SendRetryContextAccessor.MESSAGE, messageToSend); ctx.setAttribute(SendRetryContextAccessor.ADDRESS, replyTo); this.recoveryCallback.recover(ctx); return null;
ctx.setAttribute(SendRetryContextAccessor.MESSAGE, messageToSend); ctx.setAttribute(SendRetryContextAccessor.ADDRESS, replyTo); this.recoveryCallback.recover(ctx); return null;