private Advice createRetryInterceptor(final CountDownLatch latch, boolean stateful) throws Exception {
AbstractRetryOperationsInterceptorFactoryBean factory;
if (stateful) {
factory = new StatefulRetryOperationsInterceptorFactoryBean();
} else {
factory = new StatelessRetryOperationsInterceptorFactoryBean();
}
factory.setMessageRecoverer(new MessageRecoverer() {
@Override
public void recover(Message message, Throwable cause) {
logger.info("Recovered: [" + SerializationUtils.deserialize(message.getBody()).toString()+"], message: " +message);