BatchRetryTemplate.createState(getInputKeys(inputs), rollbackClassifier));
template.execute(retryCallback, BatchRetryTemplate.createState(outputs)); fail("Expected RecoverableException"); template.execute(retryCallback, BatchRetryTemplate.createState(outputs)); fail("Expected ExhaustedRetryException"); String[] result = template.execute(retryCallback, BatchRetryTemplate.createState(outputs)); assertEquals("[d, c]", Arrays.toString(result)); template.execute(retryCallback, BatchRetryTemplate.createState(outputs)); fail("Expected ExhaustedRetryException"); result = template.execute(retryCallback, BatchRetryTemplate.createState(outputs)); assertEquals("[e, f]", Arrays.toString(result));
@Test(expected = ExhaustedRetryException.class) public void testExhaustedRetry() throws Exception { BatchRetryTemplate template = new BatchRetryTemplate(); template.setRetryPolicy(new SimpleRetryPolicy(1, Collections .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true))); RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() { @Override public String[] doWithRetry(RetryContext context) throws Exception { if (count++ < 2) { throw new RecoverableException("Recoverable"); } return outputs.toArray(new String[0]); } }; outputs = Arrays.asList("a", "b"); try { template.execute(retryCallback, BatchRetryTemplate.createState(outputs)); fail("Expected RecoverableException"); } catch (RecoverableException e) { assertEquals("Recoverable", e.getMessage()); } outputs = Arrays.asList("a", "c"); template.execute(retryCallback, BatchRetryTemplate.createState(outputs)); }
template.execute(retryCallback, recoveryCallback, BatchRetryTemplate.createState(outputs)); fail("Expected RecoverableException"); String[] result = template.execute(retryCallback, recoveryCallback, BatchRetryTemplate.createState(outputs)); assertEquals("[r:b, r:c]", Arrays.toString(result));
BatchRetryTemplate.createState(getInputKeys(inputs), rollbackClassifier));
BatchRetryTemplate.createState(getInputKeys(inputs), rollbackClassifier));
BatchRetryTemplate.createState(getInputKeys(inputs), rollbackClassifier));
batchRetryTemplate.execute(retryCallback, batchRecoveryCallback, BatchRetryTemplate.createState( getInputKeys(inputs), rollbackClassifier));