batchRetryTemplate.execute(retryCallback, recoveryCallback);
return batchRetryTemplate.execute(retryCallback, recoveryCallback);
return batchRetryTemplate.execute(retryCallback, recoveryCallback);
@Test public void testSuccessfulAttempt() throws Exception { BatchRetryTemplate template = new BatchRetryTemplate(); String result = template.execute(new RetryCallback<String, Exception>() { @Override public String doWithRetry(RetryContext context) throws Exception { assertTrue("Wrong context type: " + context.getClass().getSimpleName(), context.getClass() .getSimpleName().contains("Batch")); return "2"; } }, Arrays.<RetryState> asList(new DefaultRetryState("1"))); assertEquals("2", result); }
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));
O output = batchRetryTemplate.execute(retryCallback, recoveryCallback, new DefaultRetryState( getInputKey(item), rollbackClassifier)); if (output != null) {
@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)); }
@Test public void testUnSuccessfulAttemptAndRetry() throws Exception { BatchRetryTemplate template = new BatchRetryTemplate(); RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() { @Override public String[] doWithRetry(RetryContext context) throws Exception { assertEquals(count, context.getRetryCount()); if (count++ == 0) { throw new RecoverableException("Recoverable"); } return new String[] { "a", "b" }; } }; List<RetryState> states = Arrays.<RetryState> asList(new DefaultRetryState("1"), new DefaultRetryState("2")); try { template.execute(retryCallback, states); fail("Expected RecoverableException"); } catch (RecoverableException e) { assertEquals("Recoverable", e.getMessage()); } String[] result = template.execute(retryCallback, states); assertEquals("[a, b]", Arrays.toString(result)); }
return batchRetryTemplate.execute(retryCallback, recoveryCallback);
batchRetryTemplate.execute(retryCallback, recoveryCallback);
batchRetryTemplate.execute(retryCallback, recoveryCallback);
return batchRetryTemplate.execute(retryCallback, recoveryCallback);
return batchRetryTemplate.execute(retryCallback, recoveryCallback);
batchRetryTemplate.execute(retryCallback, recoveryCallback);
return batchRetryTemplate.execute(retryCallback, recoveryCallback);
return batchRetryTemplate.execute(retryCallback, recoveryCallback);
return batchRetryTemplate.execute(retryCallback, recoveryCallback);