doTestStatefulRetry(messageCount, txSize, failFrequency, concurrentConsumers);
}
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);
latch.countDown();
}
});
if (retryTemplate == null) {
retryTemplate = new RetryTemplate();
}
factory.setRetryOperations(retryTemplate);
Advice retryInterceptor = factory.getObject();
return retryInterceptor;
}