X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=holmes-actions%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Futils%2FMsbRegister.java;h=3b72aaff6378739b81e747013854245b3dc5eb28;hb=8c5da34af36d79d6210e0ac6708079ada670b1e8;hp=79ccbdc667fff64787a36789f8ef6f77009ad060;hpb=9980653129155973f31e599d7789aae9c65828c9;p=holmes%2Fcommon.git diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java index 79ccbdc..3b72aaf 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java @@ -53,23 +53,27 @@ public class MsbRegister { int retry = 0; int interval = 5; while (null == microServiceFullInfo && retry < 20) { - log.info("Holmes Service Registration. Retry: " + retry++); - - microServiceFullInfo = client - .header("Accept", MediaType.APPLICATION_JSON) - .queryParam("createOrUpdate", true) - .post(String.format("%s://%s:%s/api/microservices/v1/services", - isHttpsEnabled ? PROTOCOL_HTTPS : PROTOCOL_HTTP, msbAddrInfo[0], msbAddrInfo[1]), - Entity.entity(msinfo, MediaType.APPLICATION_JSON), - MicroServiceFullInfo.class); - - if (null == microServiceFullInfo) { - log.warn(String.format("Failed to register the service to MSB. Sleep %ds and try again.", interval)); - threadSleep(TimeUnit.SECONDS.toSeconds(interval)); - interval += 5; - } else { - log.info("Registration succeeded!"); - break; + try { + log.info("Holmes Service Registration. Retry: " + retry++); + + microServiceFullInfo = client + .header("Accept", MediaType.APPLICATION_JSON) + .queryParam("createOrUpdate", true) + .post(String.format("%s://%s:%s/api/microservices/v1/services", + isHttpsEnabled ? PROTOCOL_HTTPS : PROTOCOL_HTTP, msbAddrInfo[0], msbAddrInfo[1]), + Entity.entity(msinfo, MediaType.APPLICATION_JSON), + MicroServiceFullInfo.class); + + if (null == microServiceFullInfo) { + log.warn(String.format("Failed to register the service to MSB. Sleep %ds and try again.", interval)); + threadSleep(TimeUnit.SECONDS.toSeconds(interval)); + interval += 5; + } else { + log.info("Registration succeeded!"); + break; + } + } catch (Exception e) { + log.warn("Unexpected exception: " + e.getMessage(), e); } }