Package org.springframework.retry.policy

Examples of org.springframework.retry.policy.MapRetryContextCache


    factory.setRetryLimit(2);
    factory.setCommitInterval(3);
    // sufficiently high so we never hit it
    factory.setSkipLimit(10);
    // set the cache limit stupidly low
    factory.setRetryContextCache(new MapRetryContextCache(0));
    ItemReader<String> provider = new ItemReader<String>() {
      @Override
      public String read() {
        String item = "" + count;
        provided.add(item);
View Full Code Here


        builder.listener(listener);
      }
    }

    if (retryContextCache == null && cacheCapacity > 0) {
      retryContextCache = new MapRetryContextCache(cacheCapacity);
    }
    builder.retryContextCache(retryContextCache);
    builder.keyGenerator(keyGenerator);
    if (retryPolicy != null) {
      builder.retryPolicy(retryPolicy);
View Full Code Here

  protected void applyConfiguration(SimpleStepBuilder<T, S> builder) {

    FaultTolerantStepBuilder<T, S> faultTolerantBuilder = (FaultTolerantStepBuilder<T, S>) builder;

    if (retryContextCache == null && cacheCapacity > 0) {
      retryContextCache = new MapRetryContextCache(cacheCapacity);
    }
    faultTolerantBuilder.retryContextCache(retryContextCache);
    for (SkipListener<T, S> listener : BatchListenerFactoryHelper.<SkipListener<T, S>> getListeners(getListeners(),
        SkipListener.class)) {
      faultTolerantBuilder.listener(listener);
View Full Code Here

  @Test
  public void testCacheCapacity() throws Throwable {

    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
    retryTemplate.setRetryContextCache(new MapRetryContextCache(1));

    RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
      public Object doWithRetry(RetryContext context) throws Exception {
        count++;
        throw new RuntimeException("Barf!");
View Full Code Here

  public void testCacheCapacityNotReachedIfRecovered() throws Throwable {

    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(1, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
    retryTemplate.setRetryPolicy(retryPolicy);
    retryTemplate.setRetryContextCache(new MapRetryContextCache(2));
    final StringHolder item = new StringHolder("foo");
    RetryState state = new DefaultRetryState(item);

    RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
      public Object doWithRetry(RetryContext context) throws Exception {
View Full Code Here

    // There will be no key for these messages so they cannot be recovered...
    messageConverter.setCreateMessageIds(false);
    this.messageConverter = messageConverter;
    // Beware of context cache busting if retry policy fails...
    this.retryTemplate = new RetryTemplate();
    this.retryTemplate.setRetryContextCache(new MapRetryContextCache(1));
    // The container should have shutdown, so there are now no active consumers
    exception.handleAssertionErrors();
    exception.expectMessage("expected:<1> but was:<0>");
    doTestStatefulRetry(messageCount, txSize, failFrequency, concurrentConsumers);
View Full Code Here

    StatefulRetryOperationsInterceptorFactoryBean fb = new StatefulRetryOperationsInterceptorFactoryBean();

    // use an external template so we can share his cache
    RetryTemplate retryTemplate = new RetryTemplate();
    RetryContextCache cache = new MapRetryContextCache();
    retryTemplate.setRetryContextCache(cache);
    fb.setRetryOperations(retryTemplate);

    // give him a reference to the retry cache so he can clean it up
    MissingMessageIdAdvice missingIdAdvice = new MissingMessageIdAdvice(cache);
View Full Code Here

    StatefulRetryOperationsInterceptorFactoryBean fb = new StatefulRetryOperationsInterceptorFactoryBean();

    // use an external template so we can share his cache
    RetryTemplate retryTemplate = new RetryTemplate();
    RetryContextCache cache = new MapRetryContextCache();
    retryTemplate.setRetryContextCache(cache);
    fb.setRetryOperations(retryTemplate);
    fb.setMessageRecoverer(new RejectAndDontRequeueRecoverer());

    // give him a reference to the retry cache so he can clean it up
View Full Code Here

TOP

Related Classes of org.springframework.retry.policy.MapRetryContextCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.