All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dennisit.vplus.data.utils.RetryUtils Maven / Gradle / Ivy

There is a newer version: 2.0.8
Show newest version
package com.github.dennisit.vplus.data.utils;

import com.github.rholder.retry.*;
import com.google.common.base.Predicates;

import java.util.concurrent.TimeUnit;

public class RetryUtils {

    /**
     * 测试过程中发现经常100ms内不能返回, 所以增加了2次50ms的重试
     */
    private Retryer retryer = RetryerBuilder.newBuilder()
            .retryIfException()
            .retryIfResult(Predicates.notNull())
            .withBlockStrategy(BlockStrategies.threadSleepStrategy())
            .withStopStrategy(StopStrategies.stopAfterAttempt(2))
            .withWaitStrategy(WaitStrategies.fixedWait(50, TimeUnit.MILLISECONDS))
            .build();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy