use of org.springframework.retry.RetryState in project spring-integration by spring-projects.
the class SpelExpressionRetryStateGeneratorTests method testBasic.
@Test
public void testBasic() {
SpelExpressionRetryStateGenerator generator = new SpelExpressionRetryStateGenerator("headers['foo']");
RetryState state = generator.determineRetryState(message);
assertEquals("bar", state.getKey());
assertFalse(((DefaultRetryState) state).isForceRefresh());
assertTrue(state.rollbackFor(new RuntimeException()));
}
use of org.springframework.retry.RetryState in project spring-integration by spring-projects.
the class SpelExpressionRetryStateGeneratorTests method testForceRefreshTrue.
@Test
public void testForceRefreshTrue() {
SpelExpressionRetryStateGenerator generator = new SpelExpressionRetryStateGenerator("headers['foo']", "headers['trueHeader']");
RetryState state = generator.determineRetryState(message);
assertEquals("bar", state.getKey());
assertTrue(((DefaultRetryState) state).isForceRefresh());
assertTrue(state.rollbackFor(new RuntimeException()));
}
use of org.springframework.retry.RetryState in project spring-integration by spring-projects.
the class SpelExpressionRetryStateGeneratorTests method testForceRefreshFalse.
@Test
public void testForceRefreshFalse() {
SpelExpressionRetryStateGenerator generator = new SpelExpressionRetryStateGenerator("headers['foo']", "headers['falseHeader']");
RetryState state = generator.determineRetryState(message);
assertEquals("bar", state.getKey());
assertFalse(((DefaultRetryState) state).isForceRefresh());
assertTrue(state.rollbackFor(new RuntimeException()));
}
use of org.springframework.retry.RetryState in project spring-integration by spring-projects.
the class RequestHandlerRetryAdvice method doInvoke.
@Override
protected Object doInvoke(final ExecutionCallback callback, Object target, final Message<?> message) throws Exception {
RetryState retryState = null;
retryState = this.retryStateGenerator.determineRetryState(message);
messageHolder.set(message);
try {
return this.retryTemplate.execute(context -> callback.cloneAndExecute(), this.recoveryCallback, retryState);
} catch (MessagingException e) {
if (e.getFailedMessage() == null) {
throw new MessagingException(message, "Failed to invoke handler", e);
}
throw e;
} catch (Exception e) {
throw new MessagingException(message, "Failed to invoke handler", unwrapExceptionIfNecessary(e));
} finally {
messageHolder.remove();
}
}
use of org.springframework.retry.RetryState in project spring-integration by spring-projects.
the class SpelExpressionRetryStateGeneratorTests method testForceRefreshElvis.
@Test
public void testForceRefreshElvis() {
SpelExpressionRetryStateGenerator generator = new SpelExpressionRetryStateGenerator("headers['foo']", "headers['noHeader']?:true");
RetryState state = generator.determineRetryState(message);
assertEquals("bar", state.getKey());
assertTrue(((DefaultRetryState) state).isForceRefresh());
assertTrue(state.rollbackFor(new RuntimeException()));
}
Aggregations