Tabnine Logo
StatefulRetryOperationsInterceptorFactoryBean
Code IndexAdd Tabnine to your IDE (free)

How to use
StatefulRetryOperationsInterceptorFactoryBean
in
org.springframework.amqp.rabbit.config

Best Java code snippets using org.springframework.amqp.rabbit.config.StatefulRetryOperationsInterceptorFactoryBean (Showing top 12 results out of 315)

origin: com.bluelock/camel-spring-amqp

/**
 * 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() };
}
origin: spring-projects/spring-amqp

@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();
}
origin: spring-projects/spring-amqp

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();
origin: spring-projects/spring-amqp

RetryOperations retryTemplate = getRetryOperations();
if (retryTemplate == null) {
  retryTemplate = new RetryTemplate();
final MessageRecoverer messageRecoverer = getMessageRecoverer();
retryInterceptor.setRecoverer((args, cause) -> {
  Message message = (Message) args[1];
origin: spring-projects/spring-amqp

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();
}
origin: org.springframework.amqp/spring-rabbit

RetryOperations retryTemplate = getRetryOperations();
if (retryTemplate == null) {
  retryTemplate = new RetryTemplate();
final MessageRecoverer messageRecoverer = getMessageRecoverer();
retryInterceptor.setRecoverer((args, cause) -> {
  Message message = (Message) args[1];
origin: Bluelock/camel-spring-amqp

/**
 * 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() };
}
origin: org.springframework.amqp/spring-rabbit

@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();
}
origin: com.dell.cpsd.common.messaging/common-rabbitmq

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();
}
origin: com.dell.cpsd/common-rabbitmq

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();
}
origin: spring-projects/spring-amqp

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();
origin: spring-projects/spring-amqp

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();
org.springframework.amqp.rabbit.configStatefulRetryOperationsInterceptorFactoryBean

Javadoc

Convenient factory bean for creating a stateful retry interceptor for use in a message listener container, giving you a large amount of control over the behaviour of a container when a listener fails. To control the number of retry attempt or the backoff in between attempts, supply a customized RetryTemplate. Stateful retry is appropriate if your listener is using a transactional resource that needs to be rollback on an exception (e.g. a stateful connection to a back end server). JPA is the canonical example. The semantics of stateful retry mean that a listener exception is propagated to the container, so that it can force a rollback. When the message is redelivered it has to be recognised (hence the MessageKeyGenerator strategy), and when the retry attempts are exhausted it will be processed using a MessageRecoverer if one is provided, in a new transaction. If a recoverer is not provided the message will be logged and dropped.

Most used methods

  • getObject
  • setMessageKeyGenerator
  • <init>
  • setRetryOperations
  • setMessageRecoverer
  • getMessageRecoverer
  • getRetryOperations
  • setNewMessageIdentifier

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSupportFragmentManager (FragmentActivity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • JTable (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now