perf(商城): 添加https支持

master
hequan_waynaqua 4 years ago
parent 7bd554a367
commit 0f243a0d23

@ -25,16 +25,16 @@ public class EmailDirectReceiver {
private RestTemplate restTemplate; private RestTemplate restTemplate;
@RabbitHandler @RabbitHandler
public void process(Map testMessage) { public void process(Map<String, Object> testMessage) {
log.info("EmailDirectReceiver消费者收到消息: {}", testMessage.toString()); log.info("EmailDirectReceiver消费者收到消息: {}", testMessage.toString());
String notifyUrl = (String) testMessage.get("notifyUrl"); String notifyUrl = (String) testMessage.get("notifyUrl");
if (StringUtils.isEmpty(notifyUrl)) { if (StringUtils.isEmpty(notifyUrl)) {
log.error("notifyUrl不能为空参数" + testMessage.toString()); log.error("notifyUrl不能为空参数{}", testMessage);
return; return;
} }
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA); headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, Object> multiValueMap = new LinkedMultiValueMap(); MultiValueMap<String, Object> multiValueMap = new LinkedMultiValueMap<>();
multiValueMap.add("subject", testMessage.get("subject")); multiValueMap.add("subject", testMessage.get("subject"));
multiValueMap.add("content", testMessage.get("content")); multiValueMap.add("content", testMessage.get("content"));
multiValueMap.add("tos", testMessage.get("tos")); multiValueMap.add("tos", testMessage.get("tos"));
@ -42,7 +42,7 @@ public class EmailDirectReceiver {
try { try {
ResponseEntity<String> response = restTemplate.postForEntity(notifyUrl, request, String.class); ResponseEntity<String> response = restTemplate.postForEntity(notifyUrl, request, String.class);
if (response.getStatusCode().value() != 200) { if (response.getStatusCode().value() != 200) {
throw new Exception(testMessage.toString() + " 邮件发送失败"); throw new Exception(testMessage + " 邮件发送失败");
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);

@ -25,22 +25,22 @@ public class OrderDirectReceiver {
private RestTemplate restTemplate; private RestTemplate restTemplate;
@RabbitHandler @RabbitHandler
public void process(Map testMessage) { public void process(Map<String, Object> testMessage) {
log.info("OrderDirectReceiver消费者收到消息: {}", testMessage.toString()); log.info("OrderDirectReceiver消费者收到消息: {}", testMessage.toString());
String notifyUrl = (String) testMessage.get("notifyUrl"); String notifyUrl = (String) testMessage.get("notifyUrl");
if (StringUtils.isEmpty(notifyUrl)) { if (StringUtils.isEmpty(notifyUrl)) {
log.error("notifyUrl不能为空参数" + testMessage.toString()); log.error("notifyUrl不能为空参数{}", testMessage);
return; return;
} }
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA); headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, Object> multiValueMap = new LinkedMultiValueMap(); MultiValueMap<String, Object> multiValueMap = new LinkedMultiValueMap<>();
multiValueMap.add("order", testMessage.get("order")); multiValueMap.add("order", testMessage.get("order"));
HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(multiValueMap, headers); HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(multiValueMap, headers);
try { try {
ResponseEntity<String> response = restTemplate.postForEntity(notifyUrl, request, String.class); ResponseEntity<String> response = restTemplate.postForEntity(notifyUrl, request, String.class);
if (response.getStatusCode().value() != 200) { if (response.getStatusCode().value() != 200) {
throw new Exception(testMessage.toString() + " 下单失败"); throw new Exception(testMessage + " 下单失败");
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);

Loading…
Cancel
Save