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