public Object doWithRetry(RetryContext context) throws Exception {
writer.write(Collections.singletonList(item));
return null;
}
};
return retryTemplate.execute(callback, new DefaultRetryState(item));
}
catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
});
fail("Expected Exception");
}
catch (Exception e) {
assertEquals("Rollback!", e.getMessage());
// Client of retry template has to take care of rollback. This would
// be a message listener container in the MDP case.
}
new TransactionTemplate(transactionManager).execute(new TransactionCallback<Object>() {
@Override
public Object doInTransaction(TransactionStatus status) {
try {
final String item = provider.read();
RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
@Override
public Object doWithRetry(RetryContext context) throws Exception {
writer.write(Collections.singletonList(item));
return null;
}
};
return retryTemplate.execute(callback, new DefaultRetryState(item));
}
catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}