summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-06-05 23:51:09 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-06-06 02:11:11 -0400
commit57c589b4026f09daf02cf6d3d73b8ce672de1b0b (patch)
treeb84a52552526b496e4cac28ef8541558d02a271d
parent329ad24f72100bb1fff3b9b4f71063dd802af858 (diff)
[AAI-ONAP] Make necessary chagnes to enable dmaap
Change-Id: I163502d5e422e57c4a6be52d0356801eb7db1b41 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
-rw-r--r--aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties28
-rw-r--r--aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml1
-rw-r--r--aai-resources/src/main/java/org/openecomp/aai/config/DmaapConfig.java42
-rw-r--r--aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java234
-rw-r--r--aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java12
5 files changed, 138 insertions, 179 deletions
diff --git a/aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties b/aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties
index 6245f84..9981919 100644
--- a/aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties
+++ b/aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties
@@ -1,28 +1,4 @@
-TransportType=DME2
-Latitude=39.099727
-Longitude=-94.578567
-Version=1.0
-ServiceName=ONAPserverTBD/events
-Environment=TEST
-routeOffer=MR1SBKCD
-SubContextPath=/
Protocol=http
-MethodType=POST
-username=ONAPserverTBD
-password=
contenttype=application/json
-host=ONAPserverTBD:3904
-topic=AAI-EVENT
-partition=AAI
-maxBatchSize=100
-maxAgeMs=250
-AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
-AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
-AFT_DME2_REQ_TRACE_ON=true
-AFT_ENVIRONMENT=AFTUAT
-AFT_DME2_EP_CONN_TIMEOUT=15000
-AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000
-AFT_DME2_EP_READ_TIMEOUT_MS=50000
-sessionstickinessrequired=NO
-DME2preferredRouterFilePath=preferredRoute.txt
-MessageSentThreadOccurance=50
+host=localhost:3904
+topic=AAI-EVENT \ No newline at end of file
diff --git a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml
index 79fe736..9d9d8f0 100644
--- a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml
+++ b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml
@@ -36,6 +36,7 @@
</cxf:outInterceptors>
</cxf:bus>
<context:component-scan base-package="org.openecomp.aai.tasks" />
+ <context:component-scan base-package="org.openecomp.aai.config" />
<task:scheduler id="taskScheduler" pool-size="10" />
<task:executor id="taskExecutor" pool-size="10"
diff --git a/aai-resources/src/main/java/org/openecomp/aai/config/DmaapConfig.java b/aai-resources/src/main/java/org/openecomp/aai/config/DmaapConfig.java
new file mode 100644
index 0000000..aeee99f
--- /dev/null
+++ b/aai-resources/src/main/java/org/openecomp/aai/config/DmaapConfig.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.config;
+
+import org.apache.activemq.broker.BrokerService;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class DmaapConfig {
+
+ @Bean(destroyMethod = "stop")
+ public BrokerService brokerService() throws Exception {
+
+ BrokerService broker = new BrokerService();
+ broker.addConnector("tcp://localhost:61447");
+ broker.setPersistent(false);
+ broker.setUseJmx(false);
+ broker.setSchedulerSupport(false);
+ broker.start();
+
+ return broker;
+ }
+}
diff --git a/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java
index c016bb1..a30ebc0 100644
--- a/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java
+++ b/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java
@@ -20,32 +20,26 @@
package org.openecomp.aai.dmaap;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Properties;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import org.apache.log4j.MDC;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.openecomp.aai.logging.ErrorLogHelper;
+import org.openecomp.aai.util.AAIConstants;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.ws.rs.core.MediaType;
-
-import org.apache.log4j.MDC;
-import org.eclipse.jetty.util.security.Password;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import org.openecomp.aai.logging.ErrorLogHelper;
-import org.openecomp.aai.util.AAIConstants;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-//import com.att.nsa.mr.client.MRBatchingPublisher;
-//import com.att.nsa.mr.client.MRClientFactory;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Properties;
public class AAIDmaapEventJMSConsumer implements MessageListener {
@@ -53,146 +47,92 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
private Client httpClient;
- //private MRBatchingPublisher aaiEventPublisher = null;
private Properties aaiEventProps;
private String aaiEventUrl = "";
- //private MRBatchingPublisher aaiVceEventPublisher = null;
- private Properties aaiVceEventProps;
- private String aaiVceEventUrl = "";
-
public AAIDmaapEventJMSConsumer() throws org.apache.commons.configuration.ConfigurationException {
- //super();
- //try {
-
- //if (this.aaiEventPublisher == null) {
- //FileReader reader = new FileReader(new File(AAIConstants.AAI_EVENT_DMAAP_PROPS));
- //aaiEventProps = new Properties();
- //aaiEventProps.load(reader);
- //reader.close();
- //aaiEventProps.setProperty("DME2preferredRouterFilePath",
- //AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "preferredRoute.txt");
- //if (aaiEventProps.getProperty("password") != null
- //&& aaiEventProps.getProperty("password").startsWith("OBF:")) {
- //aaiEventProps.setProperty("password", Password.deobfuscate(aaiEventProps.getProperty("password")));
- //}
-
- //this.aaiEventPublisher = MRClientFactory.createBatchingPublisher(aaiEventProps);
-
- //String host = aaiEventProps.getProperty("host");
- //String topic = aaiEventProps.getProperty("topic");
- //String protocol = aaiEventProps.getProperty("Protocol");
-
- //String username = aaiEventProps.getProperty("username");
- //String password = aaiEventProps.getProperty("password");
-
- //aaiEventUrl = protocol + "://" + host + "/events/" + topic;
- //httpClient = Client.create();
- //httpClient.addFilter(new HTTPBasicAuthFilter(username, password));
- //}
-
- //if (this.aaiVceEventProps == null) {
- //FileReader reader = new FileReader(new File(AAIConstants.AAI_EVENT_DMAAP_PROPS));
- //aaiVceEventProps = new Properties();
- //aaiVceEventProps.load(reader);
- //reader.close();
- //aaiVceEventProps.setProperty("DME2preferredRouterFilePath",
- //AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "preferredRoute.txt");
- //if (aaiVceEventProps.getProperty("password") != null
- //&& aaiVceEventProps.getProperty("password").startsWith("OBF:")) {
- //aaiVceEventProps.setProperty("password",
- //Password.deobfuscate(aaiVceEventProps.getProperty("password")));
- //}
- //aaiVceEventProps.setProperty("topic", "AAI-VCE-INTERFACE-DATA");
- //this.aaiVceEventPublisher = MRClientFactory.createBatchingPublisher(aaiVceEventProps);
-
- //String host = aaiVceEventProps.getProperty("host");
- //String topic = aaiVceEventProps.getProperty("topic");
- //String protocol = aaiVceEventProps.getProperty("Protocol");
-
- //aaiVceEventUrl = protocol + "://" + host + "/events/" + topic;
-
- //}
- //} catch (IOException e) {
- //ErrorLogHelper.logError("AAI_4000", "Error updating dmaap config file for aai event.");
- //}
+ super();
+ try {
+
+ if (this.httpClient == null) {
+ FileReader reader = new FileReader(new File(AAIConstants.AAI_EVENT_DMAAP_PROPS));
+ aaiEventProps = new Properties();
+ aaiEventProps.load(reader);
+ reader.close();
+
+ String host = aaiEventProps.getProperty("host");
+ String topic = aaiEventProps.getProperty("topic");
+ String protocol = aaiEventProps.getProperty("Protocol");
+
+ aaiEventUrl = protocol + "://" + host + "/events/" + topic;
+ httpClient = Client.create();
+ }
+
+ } catch (IOException e) {
+ ErrorLogHelper.logError("AAI_4000", "Error updating dmaap config file for aai event.");
+ }
}
@Override
public void onMessage(Message message) {
- //String jsmMessageTxt = "";
- //String aaiEvent = "";
- //String eventName = "";
-
-
- //String environment = "";
-
- //if (message instanceof TextMessage) {
- //try {
- //jsmMessageTxt = ((TextMessage) message).getText();
- //JSONObject jo = new JSONObject(jsmMessageTxt);
-
- //if (jo.has("aaiEventPayload")) {
- //aaiEvent = jo.getJSONObject("aaiEventPayload").toString();
- //} else {
- //return;
- //}
- //if (jo.getString("transId") != null) {
- //MDC.put("requestId", jo.getString("transId"));
- //}
- //if (jo.getString("fromAppId") != null) {
- //MDC.put("partnerName", jo.getString("fromAppId"));
- //}
- //if (jo.getString("event-topic") != null) {
- //eventName = jo.getString("event-topic");
- //}
-
- //LOGGER.info(eventName + "|" + aaiEvent);
- //if (eventName.equals("AAI-EVENT")) {
- //if (!this.sentWithHttp(environment, this.httpClient, this.aaiEventUrl, aaiEvent)) {
- //this.aaiEventPublisher.send(aaiEvent);
- //}
- //LOGGER.info(eventName + "|Event sent.");
- //} else if (eventName.equals("AAI-VCE-INTERFACE-DATA")) {
- //String msg = "";
- //if (!this.sentWithHttp(environment, this.httpClient, this.aaiVceEventUrl, aaiEvent)) {
- //this.aaiVceEventPublisher.send(aaiEvent);
- //msg = this.aaiVceEventPublisher.sendBatchWithResponse().getResponseMessage();
- //}
- //LOGGER.info(eventName + "|Event sent. " + msg);
- //} else {
- //LOGGER.error(eventName + "|Event Topic invalid.");
- //}
- //} catch (java.net.SocketException e) {
- //if (!e.getMessage().contains("Connection reset")) {
- //LOGGER.error("AAI_7304 Error reaching DMaaP to send event. " + aaiEvent, e);
- //}
- //} catch (IOException e) {
- //LOGGER.error("AAI_7304 Error reaching DMaaP to send event. " + aaiEvent, e);
- //} catch (JMSException | JSONException e) {
- //LOGGER.error("AAI_7350 Error parsing aaievent jsm message for sending to dmaap. " + jsmMessageTxt, e);
- //} catch (Exception e) {
- //LOGGER.error("AAI_7350 Error sending message to dmaap. " + jsmMessageTxt, e);
- //}
- //}
+ String jsmMessageTxt = "";
+ String aaiEvent = "";
+ String eventName = "";
+
+ if (message instanceof TextMessage) {
+ try {
+ jsmMessageTxt = ((TextMessage) message).getText();
+ JSONObject jo = new JSONObject(jsmMessageTxt);
+
+ if (jo.has("aaiEventPayload")) {
+ aaiEvent = jo.getJSONObject("aaiEventPayload").toString();
+ } else {
+ return;
+ }
+ if (jo.getString("transId") != null) {
+ MDC.put("requestId", jo.getString("transId"));
+ }
+ if (jo.getString("fromAppId") != null) {
+ MDC.put("partnerName", jo.getString("fromAppId"));
+ }
+ if (jo.getString("event-topic") != null) {
+ eventName = jo.getString("event-topic");
+ }
+
+ LOGGER.info(eventName + "|" + aaiEvent);
+ if ("AAI-EVENT".equals(eventName)) {
+ this.sentWithHttp(this.httpClient, this.aaiEventUrl, aaiEvent);
+ }
+ } catch (java.net.SocketException e) {
+ if (!e.getMessage().contains("Connection reset")) {
+ LOGGER.error("AAI_7304 Error reaching DMaaP to send event. " + aaiEvent, e);
+ }
+ } catch (IOException e) {
+ LOGGER.error("AAI_7304 Error reaching DMaaP to send event. " + aaiEvent, e);
+ } catch (JMSException | JSONException e) {
+ LOGGER.error("AAI_7350 Error parsing aaievent jsm message for sending to dmaap. " + jsmMessageTxt, e);
+ } catch (Exception e) {
+ LOGGER.error("AAI_7350 Error sending message to dmaap. " + jsmMessageTxt, e);
+ }
+ }
}
- private boolean sentWithHttp(String environment, Client client, String url, String aaiEvent) throws IOException {
- //if (environment.startsWith("dev") || environment.startsWith("testINT") || environment.startsWith("testEXT")) {
-
- //WebResource webResource = client.resource(url);
- //ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON)
- //.post(ClientResponse.class, aaiEvent);
- //if (response.getStatus() != 200) {
- //LOGGER.info("Failed : HTTP error code : " + response.getStatus());
- //return false;
- //}
- //} else {
- //return false;
- //}
+ private boolean sentWithHttp(Client client, String url, String aaiEvent) throws IOException {
+
+ WebResource webResource = client.resource(url);
+
+ ClientResponse response = webResource
+ .accept(MediaType.APPLICATION_JSON)
+ .type(MediaType.APPLICATION_JSON)
+ .post(ClientResponse.class, aaiEvent);
+
+ if (response.getStatus() != 200) {
+ LOGGER.info("Failed : HTTP error code : " + response.getStatus());
+ return false;
+ }
return true;
}
}
diff --git a/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java b/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java
index eef852a..06a4fa0 100644
--- a/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java
+++ b/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java
@@ -31,14 +31,14 @@ public class AAIDmaapEventJMSProducer {
private JmsTemplate jmsTemplate;
public AAIDmaapEventJMSProducer() {
- //this.jmsTemplate = new JmsTemplate();
- //this.jmsTemplate.setConnectionFactory(new CachingConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61447")));
- //this.jmsTemplate.setDefaultDestination(new ActiveMQQueue("IN_QUEUE"));
+ this.jmsTemplate = new JmsTemplate();
+ this.jmsTemplate.setConnectionFactory(new CachingConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61447")));
+ this.jmsTemplate.setDefaultDestination(new ActiveMQQueue("IN_QUEUE"));
}
public void sendMessageToDefaultDestination(JSONObject finalJson) {
- //jmsTemplate.convertAndSend(finalJson.toString());
- //CachingConnectionFactory ccf = (CachingConnectionFactory)this.jmsTemplate.getConnectionFactory();
- //ccf.destroy();
+ jmsTemplate.convertAndSend(finalJson.toString());
+ CachingConnectionFactory ccf = (CachingConnectionFactory)this.jmsTemplate.getConnectionFactory();
+ ccf.destroy();
}
}