优化了sdk的feign请求超时变量

This commit is contained in:
ajaxfan
2021-03-19 14:28:27 +08:00
parent d3c4b23e03
commit 4a35c0508b
3 changed files with 26 additions and 18 deletions

View File

@ -212,8 +212,7 @@ public class DefaultAttachmentClient implements AttachmentClient {
public Optional<UploadObject> upload(@NotNull String businessId, @NotNull String filename, @NotNull byte[] array) {
removeDuplicateObject(businessId, filename);
String res = documentCenterService.upload("ebtp-mall-cloud", businessId,
fileConvertor.toMultipartFile(filename, array));
String res = documentCenterService.upload("ebtp-mall-cloud", businessId, fileConvertor.toMultipartFile(filename, array));
log.info("document center upload result: {}", res);
@ -255,7 +254,7 @@ public class DefaultAttachmentClient implements AttachmentClient {
* @param filename
*/
private void removeDuplicateObject(String businessId, String filename) {
log.info("remove duplicate name files {} in business: {}", filename, businessId);
log.info("remove files {} in business: {} if exists", filename, businessId);
Optional<AttachmentDetail> op = findByBusinessId(Arrays.asList(businessId));
op.ifPresent(detail -> {

View File

@ -45,12 +45,14 @@ public class ModelConvertor {
AttachmentEntity entity = null;
try {
SysStorageVO vo = tpDownPO(content);
log.debug("convert to model: {}", vo);
Optional<SysStorageVO> op = tpDownPO(content);
entity = new AttachmentEntity();
entity.setId(vo.getFileId()).setFilename(vo.getOriginalName()).setBid(vo.getObjectId())
.setKey(vo.getFileName());
if (op.isPresent()) {
SysStorageVO vo = op.get();
entity = new AttachmentEntity();
entity.setId(vo.getFileId()).setFilename(vo.getOriginalName()).setBid(vo.getObjectId())
.setKey(vo.getFileName());
}
} catch (JsonProcessingException e) {
log.error(json);
log.error(e.getMessage());
@ -82,7 +84,11 @@ public class ModelConvertor {
public Optional<byte[]> toByteArray(String json) {
return Optional.ofNullable(json).map(content -> {
try {
return tpDownPO(content).getFileStream();
Optional<SysStorageVO> op = tpDownPO(content);
if (op.isPresent()) {
return op.get().getFileStream();
}
} catch (JsonProcessingException e) {
log.error(json);
log.error(e.getMessage());
@ -99,18 +105,20 @@ public class ModelConvertor {
return Optional.ofNullable(json).map(content -> {
DownloadEntity entity = null;
try {
SysStorageVO vo = tpDownPO(content);
Optional<SysStorageVO> op = tpDownPO(content);
entity = new DownloadEntity();
entity.setFilename(URLEncoder.DEFAULT.encode(vo.getOriginalName(), Charset.forName("UTF-8")))
.setStream(vo.getFileStream());
if (op.isPresent()) {
SysStorageVO vo = op.get();
entity = new DownloadEntity();
entity.setFilename(URLEncoder.DEFAULT.encode(vo.getOriginalName(), Charset.forName("UTF-8")))
.setStream(vo.getFileStream());
}
} catch (JsonProcessingException e) {
log.error(json);
log.error(e.getMessage());
}
return entity;
});
}
/**
@ -138,10 +146,10 @@ public class ModelConvertor {
* @throws JsonMappingException
* @throws JsonProcessingException
*/
private SysStorageVO tpDownPO(String json) throws JsonMappingException, JsonProcessingException {
private Optional<SysStorageVO> tpDownPO(String json) throws JsonMappingException, JsonProcessingException {
log.debug("current convertor json is: {}", json);
return Optional.ofNullable(objectMapper.readValue(json, DownStream.class)).map(ds -> ds.getData())
.map(data -> data.getSysStorageVO()).orElseGet(SysStorageVO::new);
.map(data -> data.getSysStorageVO());
}
/**

View File

@ -1,5 +1,6 @@
ribbon.ReadTimeout=1800000
ribbon.SocketTimeout=1800000
feign.hystrix.enabled=true
feign.client.config.default.retryer=feign.Retryer.Default
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=600000
# document center id
document.center.service.id=core-service-document-center