We're using RabbitMQ in our application to queue payment requests, and have another queue to send results back to the caller. In both cases, the client has requested a retry policy that will retry forever, but will put something in the log on each retry like "Retrying transaction for the xth time..." so that an external system can detect stuff backing up by monitoring the log file.
I'm creating listener container thus:
public SimpleMessageListenerContainer paymentListenerContainer() {
final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(rabbitConnectionFactory());
container.setQueues(paymentQueue());
container.setMessageListener(cpmPaymentListener());
container.setConcurrentConsumers(configurationService.getAmqpConcurrentConsumers());
container.setMaxConcurrentConsumers(configurationService.getAmqpMaxConcurrentConsumers());
container.setAdviceChain(new Advice[] { paymentRetryInterceptor() });
return container;
}
and defining the retry logic thus:
public RetryOperationsInterceptor paymentRetryInterceptor() {
return RetryInterceptorBuilder.stateless()
.maxAttempts(configurationService.getPaymentRetryMaxAttempts())
.backOffOptions(configurationService.getPaymentRetryInitialInterval(), configurationService.getPaymentRetryMultiplier(), configurationService.getPaymentRetryMaxInterval()) // initialInterval, multiplier, maxInterval
.build();
}
So the retry works flawlessly, but I can't find a hook to actually log anything on the retries. Is there something I'm missing? Is there a hook in there somewhere to execute something on the retry? Something I can subclass? Or is there some exsting logging buried within the retry logic in Spring that I can just enable in my logger config?
Thanks.
Chris.