/** * Do not have Spring AMQP re-try messages upon failure, leave it to Camel * @return An advice chain populated with a NeverRetryPolicy */ public final Advice[] getAdviceChain() { RetryTemplate retryRule = new RetryTemplate(); retryRule.setRetryPolicy(new NeverRetryPolicy()); StatefulRetryOperationsInterceptorFactoryBean retryOperation = new StatefulRetryOperationsInterceptorFactoryBean(); retryOperation.setRetryOperations(retryRule); retryOperation.setMessageKeyGenerator(new DefaultKeyGenerator()); return new Advice[] { retryOperation.getObject() }; }
@Override public StatefulRetryOperationsInterceptor build() { this.applyCommonSettings(this.factoryBean); if (this.messageKeyGenerator != null) { this.factoryBean.setMessageKeyGenerator(this.messageKeyGenerator); } if (this.newMessageIdentifier != null) { this.factoryBean.setNewMessageIdentifier(this.newMessageIdentifier); } return this.factoryBean.getObject(); }
container.setQueueNames("retry.test.queue"); StatefulRetryOperationsInterceptorFactoryBean fb = new StatefulRetryOperationsInterceptorFactoryBean(); RetryContextCache cache = spy(new MapRetryContextCache()); retryTemplate.setRetryContextCache(cache); fb.setRetryOperations(retryTemplate); Advice retryInterceptor = fb.getObject(); container.setAdviceChain(retryInterceptor); container.start();
RetryOperations retryTemplate = getRetryOperations(); if (retryTemplate == null) { retryTemplate = new RetryTemplate(); final MessageRecoverer messageRecoverer = getMessageRecoverer(); retryInterceptor.setRecoverer((args, cause) -> { Message message = (Message) args[1];
private Advice createRetryInterceptor(final CountDownLatch latch, boolean stateful) throws Exception { AbstractRetryOperationsInterceptorFactoryBean factory; if (stateful) { factory = new StatefulRetryOperationsInterceptorFactoryBean(); } else { factory = new StatelessRetryOperationsInterceptorFactoryBean(); } factory.setMessageRecoverer((message, cause) -> { logger.warn("Recovered: [" + SerializationUtils.deserialize(message.getBody()).toString() + "], message: " + message); latch.countDown(); }); if (retryTemplate == null) { retryTemplate = new RetryTemplate(); } factory.setRetryOperations(retryTemplate); return factory.getObject(); }
RetryOperations retryTemplate = getRetryOperations(); if (retryTemplate == null) { retryTemplate = new RetryTemplate(); final MessageRecoverer messageRecoverer = getMessageRecoverer(); retryInterceptor.setRecoverer((args, cause) -> { Message message = (Message) args[1];
/** * Do not have Spring AMQP re-try messages upon failure, leave it to Camel * @return An advice chain populated with a NeverRetryPolicy */ public final Advice[] getAdviceChain() { RetryTemplate retryRule = new RetryTemplate(); retryRule.setRetryPolicy(new NeverRetryPolicy()); StatefulRetryOperationsInterceptorFactoryBean retryOperation = new StatefulRetryOperationsInterceptorFactoryBean(); retryOperation.setRetryOperations(retryRule); retryOperation.setMessageKeyGenerator(new DefaultKeyGenerator()); return new Advice[] { retryOperation.getObject() }; }
@Override public StatefulRetryOperationsInterceptor build() { this.applyCommonSettings(this.factoryBean); if (this.messageKeyGenerator != null) { this.factoryBean.setMessageKeyGenerator(this.messageKeyGenerator); } if (this.newMessageIdentifier != null) { this.factoryBean.setNewMessageIdentifier(this.newMessageIdentifier); } return this.factoryBean.getObject(); }
public DefaultRetryPolicyAdvice(MessageRecoverer messageRecoverer, RetryPolicy retryPolicy) { RetryTemplate retryTemplate = new RetryTemplate(); retryTemplate.setBackOffPolicy(createBackOffPolicy()); retryTemplate.setRetryPolicy(retryPolicy); retryTemplate.registerListener(new RetryErrorListener()); StatefulRetryOperationsInterceptorFactoryBean factory = new StatefulRetryOperationsInterceptorFactoryBean(); factory.setRetryOperations(retryTemplate); factory.setMessageKeyGenerator(new DefaultMessageKeyGenerator()); factory.setMessageRecoverer(messageRecoverer); this.delegate = factory.getObject(); }
public DefaultRetryPolicyAdvice(MessageRecoverer messageRecoverer, RetryPolicy retryPolicy) { RetryTemplate retryTemplate = new RetryTemplate(); retryTemplate.setBackOffPolicy(createBackOffPolicy()); retryTemplate.setRetryPolicy(retryPolicy); retryTemplate.registerListener(new RetryErrorListener()); StatefulRetryOperationsInterceptorFactoryBean factory = new StatefulRetryOperationsInterceptorFactoryBean(); factory.setRetryOperations(retryTemplate); factory.setMessageKeyGenerator(new DefaultMessageKeyGenerator()); factory.setMessageRecoverer(messageRecoverer); this.delegate = factory.getObject(); }
container.setQueueNames("retry.test.queue"); StatefulRetryOperationsInterceptorFactoryBean fb = new StatefulRetryOperationsInterceptorFactoryBean(); RetryContextCache cache = spy(new MapRetryContextCache()); retryTemplate.setRetryContextCache(cache); fb.setRetryOperations(retryTemplate); fb.setMessageRecoverer(new RejectAndDontRequeueRecoverer()); Advice retryInterceptor = fb.getObject(); container.setAdviceChain(retryInterceptor); container.start();
container.setQueueNames("retry.test.queue"); StatefulRetryOperationsInterceptorFactoryBean fb = new StatefulRetryOperationsInterceptorFactoryBean(); RetryContextCache cache = spy(new MapRetryContextCache()); retryTemplate.setRetryContextCache(cache); fb.setRetryOperations(retryTemplate); fb.setMessageRecoverer(new RejectAndDontRequeueRecoverer()); Advice retryInterceptor = fb.getObject(); container.setAdviceChain(retryInterceptor); container.start();