X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fdmaap%2FDmaapMessageHandler.java;h=efdccd87697bdc78a44bf3435560136d2818d71e;hb=4e7db50d7fb3fd2c7101520f00f0f0b4baf9bddc;hp=19d156488c679b6e807dc9abf81e054c5e1efc8d;hpb=5056cc12ba520568fcfd28132d815cf3d2afc8b0;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java index 19d15648..efdccd87 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java @@ -24,10 +24,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; -import java.io.IOException; import java.util.Optional; -import org.onap.dmaap.mr.client.MRBatchingPublisher; import org.oransc.policyagent.clients.AsyncRestClient; import org.oransc.policyagent.dmaap.DmaapRequestMessage.Operation; import org.oransc.policyagent.exceptions.ServiceException; @@ -49,10 +47,10 @@ public class DmaapMessageHandler { private static final Logger logger = LoggerFactory.getLogger(DmaapMessageHandler.class); private static Gson gson = new GsonBuilder() // .create(); // - private final MRBatchingPublisher dmaapClient; + private final AsyncRestClient dmaapClient; private final AsyncRestClient agentClient; - public DmaapMessageHandler(MRBatchingPublisher dmaapClient, AsyncRestClient agentClient) { + public DmaapMessageHandler(AsyncRestClient dmaapClient, AsyncRestClient agentClient) { this.agentClient = agentClient; this.dmaapClient = dmaapClient; } @@ -99,11 +97,7 @@ public class DmaapMessageHandler { } private String prepareBadOperationErrorMessage(Throwable t, String originalMessage) { - String operationParameterStart = "operation\":\""; - int indexOfOperationStart = originalMessage.indexOf(operationParameterStart) + operationParameterStart.length(); - int indexOfOperationEnd = originalMessage.indexOf("\",\"", indexOfOperationStart); - String badOperation = originalMessage.substring(indexOfOperationStart, indexOfOperationEnd); - return t.getMessage().replace("null", badOperation); + return t.getMessage(); } private Mono> invokePolicyAgent(DmaapRequestMessage dmaapRequestMessage) { @@ -141,14 +135,8 @@ public class DmaapMessageHandler { } private Mono sendToDmaap(String body) { - try { - logger.debug("sendToDmaap: {} ", body); - dmaapClient.send(body); - dmaapClient.sendBatchWithResponse(); - return Mono.just("OK"); - } catch (IOException e) { - return Mono.error(e); - } + logger.debug("sendToDmaap: {} ", body); + return dmaapClient.post("", "[" + body + "]"); } private Mono handleResponseCallError(Throwable t) {