로컬 테스트 완료
This commit is contained in:
@@ -4,17 +4,23 @@ import com.eactive.ext.kjb.common.KjbProperty;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||
import org.apache.hc.core5.http.io.entity.EntityUtils;
|
||||
import org.apache.hc.core5.net.URIBuilder;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
@Slf4j
|
||||
public class KjbEaiBatchModule {
|
||||
private final KjbProperty property;
|
||||
private final CloseableHttpClient httpClient;
|
||||
private final RequestConfig requestConfig;
|
||||
|
||||
|
||||
public KjbEaiBatchModule(@NotNull KjbProperty property) {
|
||||
@@ -23,6 +29,10 @@ public class KjbEaiBatchModule {
|
||||
}
|
||||
|
||||
this.property = property;
|
||||
requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(Timeout.ofSeconds(property.getEaiBatchConnectionTimeout()))
|
||||
.setResponseTimeout(Timeout.ofSeconds(property.getEaiBatchResponseTimeout()))
|
||||
.build();
|
||||
|
||||
if (StringUtils.isNotEmpty(property.getEaiBatchUrl())) {
|
||||
this.httpClient = HttpClients.createDefault();
|
||||
@@ -37,8 +47,18 @@ public class KjbEaiBatchModule {
|
||||
log.debug("EAI 배치 호출: {}", reqMessage);
|
||||
|
||||
if (this.httpClient != null) {
|
||||
String url = property.getEaiBatchUrl() + "?eaibatMsg=" + reqMessage.toString();
|
||||
final HttpGet httpGet = new HttpGet(url);
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URIBuilder(property.getEaiBatchUrl())
|
||||
.addParameter("eaibatMsg", reqMessage.toString())
|
||||
.build();
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
log.debug("EAI Batch call - {}", uri.toASCIIString());
|
||||
|
||||
final HttpGet httpGet = new HttpGet(uri);
|
||||
httpGet.setConfig(requestConfig);
|
||||
|
||||
String message = httpClient.execute(httpGet, response -> EntityUtils.toString(response.getEntity(), "EUC-KR"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user