【update】回调接口修改为Redis消息队列存储
This commit is contained in:
parent
d6963666f4
commit
792c701eb4
|
@ -24,6 +24,8 @@ public class CommonMessageConstant {
|
|||
public static final String RESULT_ERROR_CODE = "0";
|
||||
public static final String RESULT_SSO_LOGIN_ERROR_CODE = "-2";
|
||||
|
||||
public static final String COMMON_BACK = "CommonBack";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chint.domain.aggregates.order.OrderTravel;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.ly.LYNoteResponse;
|
||||
|
@ -22,6 +23,10 @@ import com.google.gson.Gson;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -29,11 +34,12 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/public/common")
|
||||
@EnableAsync
|
||||
public class CommonController {
|
||||
|
||||
@Autowired
|
||||
|
@ -54,6 +60,9 @@ public class CommonController {
|
|||
@Autowired
|
||||
private PostRequest basePostRequest;
|
||||
|
||||
@Autowired
|
||||
public RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
@Value("${ly.baseUrl}")
|
||||
private String lyBaseUrl;
|
||||
|
||||
|
@ -89,17 +98,37 @@ public class CommonController {
|
|||
}
|
||||
|
||||
String json = gson.toJson(notification);
|
||||
log.info(json);
|
||||
log.info("存入Redis{}",json);
|
||||
redisTemplate.opsForList().leftPush(CommonMessageConstant.COMMON_BACK,json);
|
||||
return new LYNoteResponse("100", "OK");
|
||||
}
|
||||
|
||||
@Scheduled(cron="0/10 * * * * ?")
|
||||
@Async
|
||||
public void scanPendingMsg() {
|
||||
int i=0;
|
||||
while (true) {
|
||||
Object object = redisTemplate.opsForList().rightPop(CommonMessageConstant.COMMON_BACK, 1, TimeUnit.SECONDS);
|
||||
if (null == object) {
|
||||
return;
|
||||
}
|
||||
String msg = JSON.toJSONString(object);
|
||||
Notification notification=gson.fromJson(msg,Notification.class);
|
||||
int notifyType = notification.getNotifyType();
|
||||
return switch (notifyType) {
|
||||
switch (notifyType) {
|
||||
//进行订单数据回推
|
||||
case 1 -> getOrderFlight(notification);
|
||||
case 3 -> getOrderHotel(notification);
|
||||
case 5 -> getOrderTrain(notification);
|
||||
case 6 -> getOrderCar(notification);
|
||||
default -> new LYNoteResponse("100", "OK");
|
||||
};
|
||||
i++;
|
||||
if (i>5){
|
||||
log.info("CommonBack处理结束");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue