spring boot项目配置RestTemplate超时时长
程序员文章站
2022-12-26 11:53:58
配置类: 调用: ......
配置类:
@configuration public class feignconfiguration { @bean(name="remoteresttemplate") public resttemplate resttemplate(){ simpleclienthttprequestfactory requestfactory = new simpleclienthttprequestfactory(); requestfactory.setconnecttimeout(5000); requestfactory.setreadtimeout(3500); resttemplate resttemplate = new resttemplate(requestfactory); return resttemplate; } }
调用:
@service @slf4j public class slcustomercreditsettingproductserviceimpl implements slcustomercreditsettingproductservice { @autowired private slcustomercreditsettingproductfeignclient slcustomercreditsettingproductfeignclient; @autowired @qualifier(value = "remoteresttemplate") private resttemplate resttemplate; @value("${crb_hub_url}") private string crbhuburl; @autowired private mqserverservice mqserverservice; @override public list<slcustomercreditsettingproductrespvo> getcustomercreditsettingproductrespvo(userinfo userinfo) throws openhttpexection{ slcustomercreditsettingproductqueryvo slcustomercreditsettingproductqueryvo = new slcustomercreditsettingproductqueryvo(); slcustomercreditsettingproductqueryvo.setcorporationid(userinfo.getcorporationid()); slcustomercreditsettingproductqueryvo.setcustomerid(userinfo.getcustomerid()); slcustomercreditsettingproductqueryvo.seteffectiveenddate(userinfo.getmakedate()); slcustomercreditsettingproductqueryvo.setmakedate(userinfo.getmakedate()); slcustomercreditsettingproductqueryvo.setregioncode(userinfo.getregioncode()); list<slcustomercreditsettingproductrespvo> slcustomercreditsettingproductrespvos = lists.newarraylist(); parameterizedtypereference<list<customercreditsettingproduct>> typeref = new parameterizedtypereference<list<customercreditsettingproduct>>() {}; responseentity<list<customercreditsettingproduct>> customercreditsettingproductrespvos; //post调用外部接口 try { customercreditsettingproductrespvos = resttemplate.exchange( crbhuburl+"/customercreditsettingproductapicontroller/findbycustomeridandcorporationid", httpmethod.post, new httpentity<>(slcustomercreditsettingproductqueryvo), typeref); }catch (exception e){ throw new openhttpexection(e.getmessage()); } if(collectionutils.isnotempty(customercreditsettingproductrespvos.getbody())) { for (customercreditsettingproduct o : customercreditsettingproductrespvos.getbody()) { slcustomercreditsettingproductrespvo slcustomercreditsettingproductrespvo = new slcustomercreditsettingproductrespvo(); beanutils.copyproperties(o, slcustomercreditsettingproductrespvo); slcustomercreditsettingproductrespvos.add(slcustomercreditsettingproductrespvo); } //mq发送数据 synslcustomercreditsettingproduct synslcustomercreditsettingproduct = new synslcustomercreditsettingproduct(); synslcustomercreditsettingproduct.setcustomercreditsettingproducts(customercreditsettingproductrespvos.getbody()); synslcustomercreditsettingproduct.setslcustomercreditsettingproductqueryvo(slcustomercreditsettingproductqueryvo); try { mqserverservice.sendloopcedit(synslcustomercreditsettingproduct); }catch (exception e){ e.printstacktrace(); log.error("同步客户信用体系设定数据到本地数据库失败!"); } } return slcustomercreditsettingproductrespvos; } }
下一篇: php 归并排序 数组交集
推荐阅读
-
Jenkins + Docker + dockerfile-maven-plugin + Harbor CI/CD spring-boot项目的最轻量级配置
-
Spring Boot项目添加外部Jar包以及配置多数据源的完整步骤
-
spring boot项目配置RestTemplate超时时长
-
Maven 仓库 修改镜像为阿里云*仓库镜像 eclipse配置 Spring Boot 项目配置
-
关于Spring Boot项目的 log4j2 核弹漏洞问题(一行代码配置搞定)
-
spring boot 配置 RestTemplate
-
spring boot项目配置多个环境
-
第004课:Spring Boot 项目属性配置
-
Spring Boot(二)项目属性配置
-
Spring boot项目配置SSL