ums 실제 보내도록 주석 제거.
UmsService에서 ums 서버정보 프로퍼티(UMS)에서 받도록 추가.
This commit is contained in:
@@ -116,8 +116,7 @@ public class AlarmStateManager {
|
|||||||
.content(ObpMonitoringUmsTemplate.builder().message(event.getMessage()).build())
|
.content(ObpMonitoringUmsTemplate.builder().message(event.getMessage()).build())
|
||||||
.cellphone(cellPhone).build();
|
.cellphone(cellPhone).build();
|
||||||
|
|
||||||
// usmService.send(payload);
|
usmService.send(payload);
|
||||||
logger.info("UMS Send!!, {}", payload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.apache.hc.core5.util.Timeout;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StreamUtils;
|
import org.springframework.util.StreamUtils;
|
||||||
|
|
||||||
|
import com.eactive.eai.common.property.PropManager;
|
||||||
import com.eactive.eai.common.util.Jsons;
|
import com.eactive.eai.common.util.Jsons;
|
||||||
import com.eactive.eai.common.util.Logger;
|
import com.eactive.eai.common.util.Logger;
|
||||||
import com.eactive.eai.custom.alarm.ums.payload.UmsRequestPayload;
|
import com.eactive.eai.custom.alarm.ums.payload.UmsRequestPayload;
|
||||||
@@ -30,8 +31,12 @@ public class UmsService {
|
|||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
protected static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||||
|
|
||||||
|
private final static String UMS_GROUP_PROP_NAME = "UMS";
|
||||||
|
private final static String UMS_PROP_HOST = "host";
|
||||||
|
private final static String UMS_PROP_URL = "url";
|
||||||
|
private final static String UMS_PROP_API_KEY = "apiKey";
|
||||||
private final static String UMS_URL = "http://172.31.35.144:9021";
|
private final static String UMS_URL = "http://172.31.35.144:9021";
|
||||||
private final static String API_KEY = "API_KEY";
|
private final static String API_KEY = "7cca6d58-e4f7-474d-9edd-525806bc99ff";
|
||||||
private final static String SEND_URL = "/ums/openapi/send";
|
private final static String SEND_URL = "/ums/openapi/send";
|
||||||
private final static String CONTENT_TYPE = "application/json; charset=utf-8";
|
private final static String CONTENT_TYPE = "application/json; charset=utf-8";
|
||||||
private final static String AUTHORIZATION_FMT = "Bearer %s";
|
private final static String AUTHORIZATION_FMT = "Bearer %s";
|
||||||
@@ -42,11 +47,6 @@ public class UmsService {
|
|||||||
throw new IllegalArgumentException("content is null");
|
throw new IllegalArgumentException("content is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UmsRequestPayload payload = UmsRequestPayload.builder()
|
|
||||||
// .content(ObpMonitoringUmsTemplate.builder().message(message).build()).cellphone(cpno)
|
|
||||||
// .build();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ValidationUtil.validateOrThrow(payload);
|
ValidationUtil.validateOrThrow(payload);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -54,22 +54,26 @@ public class UmsService {
|
|||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
return call(SEND_URL, payload);
|
return call(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CloseableHttpClient createHttpClient() {
|
private CloseableHttpClient createHttpClient() {
|
||||||
return HttpClients.createDefault();
|
return HttpClients.createDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Future<UmsCallResult> call(String url, UmsRequestPayload requestPayload) throws Exception {
|
private Future<UmsCallResult> call(UmsRequestPayload requestPayload) throws Exception {
|
||||||
|
|
||||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
String json = Jsons.GSON.toJson(requestPayload);
|
String json = Jsons.GSON.toJson(requestPayload);
|
||||||
|
|
||||||
|
String host = PropManager.getInstance().getProperty(UMS_GROUP_PROP_NAME, UMS_PROP_HOST, UMS_URL);
|
||||||
|
String url = PropManager.getInstance().getProperty(UMS_GROUP_PROP_NAME, UMS_PROP_URL, SEND_URL);
|
||||||
|
String apiKey = PropManager.getInstance().getProperty(UMS_GROUP_PROP_NAME, UMS_PROP_API_KEY, API_KEY);
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost(UMS_URL + url);
|
HttpPost httpPost = new HttpPost(host + url);
|
||||||
httpPost.setHeader("Content-Type", CONTENT_TYPE);
|
httpPost.setHeader("Content-Type", CONTENT_TYPE);
|
||||||
httpPost.setHeader("Authorization", String.format(AUTHORIZATION_FMT, API_KEY));
|
httpPost.setHeader("Authorization", String.format(AUTHORIZATION_FMT, apiKey));
|
||||||
httpPost.setEntity(EntityBuilder.create().setText(json).setContentType(ContentType.APPLICATION_JSON).build());
|
httpPost.setEntity(EntityBuilder.create().setText(json).setContentType(ContentType.APPLICATION_JSON).build());
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user