package org.onap.aai.dmaap;
+import java.util.Map;
+import java.util.Objects;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.aailog.logs.AaiDmaapMetricLog;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.TextMessage;
-import java.util.Map;
-import java.util.Objects;
-
public class AAIDmaapEventJMSConsumer implements MessageListener {
private static final String EVENT_TOPIC = "event-topic";
private Environment environment;
private Map<String, String> mdcCopy;
-
public AAIDmaapEventJMSConsumer(Environment environment, RestTemplate restTemplate, HttpHeaders httpHeaders) {
super();
mdcCopy = MDC.getCopyOfContextMap();
String aaiElsErrorCode = AaiElsErrorCode.SUCCESS;
String errorDescription = "";
- if ( mdcCopy != null ) {
+ if (mdcCopy != null) {
MDC.setContextMap(mdcCopy);
}
if (aaiEventHeader.has("entity-link")) {
serviceName = aaiEventHeader.get("entity-link").toString();
}
- }
- catch (JSONException jexc) {
+ } catch (JSONException jexc) {
// ignore, this is just used for logging
}
}
metricLog.pre(eventName, aaiEvent, transactionId, serviceName);
- HttpEntity httpEntity = new HttpEntity(aaiEvent, httpHeaders);
+ HttpEntity<String> httpEntity = new HttpEntity<String>(aaiEvent, httpHeaders);
String transportType = environment.getProperty("dmaap.ribbon.transportType", "http");
String baseUrl = transportType + "://" + environment.getProperty("dmaap.ribbon.listOfServers");
aaiElsErrorCode = AaiElsErrorCode.AVAILABILITY_TIMEOUT_ERROR;
errorDescription = e.getMessage();
ErrorLogHelper.logException(new AAIException("AAI_7304", jsmMessageTxt));
- }
- finally {
+ } finally {
metricLog.post(aaiElsErrorCode, errorDescription);
}
}