X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fdmaap%2FDmaapMessageConsumer.java;h=46dd2ee2a3a4cfe330dd14592988fd3963a401c3;hb=61d78df4c74f93d77bc56eaa51280a8cead66209;hp=91f9ff22bfe049b582028e5cb3da1067eace8478;hpb=86b589317c67eb2350870c9c57c35eac3e9056f6;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumer.java b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumer.java index 91f9ff22..46dd2ee2 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumer.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumer.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * O-RAN-SC * %% - * Copyright (C) 2019 Nordix Foundation + * Copyright (C) 2020 Nordix Foundation * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ package org.oransc.policyagent.dmaap; import com.google.common.collect.Iterables; -import java.io.FileNotFoundException; import java.io.IOException; import java.time.Duration; import java.util.Properties; @@ -45,7 +44,9 @@ public class DmaapMessageConsumer implements Runnable { private static final Logger logger = LoggerFactory.getLogger(DmaapMessageConsumer.class); + @SuppressWarnings("squid:S00116") // To avoid warning about DMAAP abbreviation. final Duration TIME_BETWEEN_DMAAP_POLLS = Duration.ofSeconds(10); + private final ApplicationConfig applicationConfig; @Value("${server.port}") @@ -83,7 +84,7 @@ public class DmaapMessageConsumer implements Runnable { } } - private Iterable fetchAllMessages() throws ServiceException, FileNotFoundException, IOException { + private Iterable fetchAllMessages() throws ServiceException, IOException { Properties dmaapConsumerProperties = this.applicationConfig.getDmaapConsumerConfig(); MRConsumer consumer = MRClientFactory.createConsumer(dmaapConsumerProperties); MRConsumerResponse response = consumer.fetchWithReturnConsumerResponse(); @@ -95,18 +96,18 @@ public class DmaapMessageConsumer implements Runnable { } } - private void processMsg(String msg) throws Exception { + private void processMsg(String msg) throws IOException { logger.debug("Message Reveived from DMAAP : {}", msg); createDmaapMessageHandler().handleDmaapMsg(msg); } - private DmaapMessageHandler createDmaapMessageHandler() throws FileNotFoundException, IOException { + private DmaapMessageHandler createDmaapMessageHandler() throws IOException { String agentBaseUrl = "http://localhost:" + this.localServerPort; AsyncRestClient agentClient = new AsyncRestClient(agentBaseUrl); Properties dmaapPublisherProperties = applicationConfig.getDmaapPublisherConfig(); MRBatchingPublisher producer = MRClientFactory.createBatchingPublisher(dmaapPublisherProperties); - return new DmaapMessageHandler(producer, this.applicationConfig, agentClient); + return new DmaapMessageHandler(producer, agentClient); } private boolean sleep(Duration duration) {