mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 19:06:49 +08:00
Retryable
This commit is contained in:
@@ -228,7 +228,11 @@
|
||||
<artifactId>elasticsearch-rest-client</artifactId>
|
||||
<version>7.9.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.retry</groupId>
|
||||
<artifactId>spring-retry</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -15,6 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
@EnableAsync
|
||||
@EnableRetry
|
||||
public class BoeServerAllApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -6,6 +6,8 @@ import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.retry.annotation.Recover;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.account.dao.AccountDao;
|
||||
@@ -40,7 +42,8 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService{
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public synchronized void syncUserFull(UserData user) {
|
||||
@Retryable
|
||||
public void syncUserFull(UserData user) {
|
||||
log.info("同步用户【"+user.getId()+","+user.getCode()+"】");
|
||||
//如果删除状态为空,则设置为不删除
|
||||
if(user.getDeleted()==null) {
|
||||
@@ -154,4 +157,10 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Recover
|
||||
private void recover() {
|
||||
System.out.println("重试3次都失败-----recover-------------recover-------------");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user