想要远程调用,你会遇到哪些问题?
远程调用,A系统的服务调用B系统的服务,很多没有经历过分布式系统实战的一部分同学就会像我以前的时候一样,用http方法,用springboot的restTemplate去调用,RestTemplate是Spring提供的用于访问Rest服务的客户端,RestTemplate提供了多种便捷访问远程Http服务的方法。
比如代码就像下面这样:
ResponseEntity<RecoveryTestActionLog> recoveryTestActionLogQueryResponseEntity =
restTemplate.postForEntity(url, collectionRecoveryLogDO, RecoveryTestActionLog.class);
完成的一个接口代码
/**
* 执行测试还原动作
*
* @param collectionRecoveryLogDO
* @return 返回RecoveryTestActionLogQuery
*/
@PostMapping("/collection/recovery/test-actionOld")
public ResponseEntity<RecoveryTestActionLog> testRecoveryData(
@RequestBody CollectionRecoveryLogDO collectionRecoveryLogDO) throws Exception {
logger.info("start to test recovering data...");
String userA