2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 *=================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.universalvesadapter.service;
22 import org.onap.universalvesadapter.dmaap.Creator;
23 import org.onap.universalvesadapter.dmaap.MRPublisher.DMaaPMRPublisher;
24 import org.onap.universalvesadapter.dmaap.MRSubcriber.DMaaPMRSubscriber;
25 import org.onap.universalvesadapter.exception.MapperConfigException;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Component;
32 * Service that starts the universal ves adapter module to listen for events
38 public class VesService {
40 private final Logger LOGGER = LoggerFactory.getLogger(VesService.class);
42 private boolean isRunning = true;
45 private DMaapService dmaapService;
48 private Creator creator;
52 * method triggers universal VES adapter module.
54 public void start() throws MapperConfigException {
55 LOGGER.debug("Creating Subcriber and Publisher with creator.............");
56 DMaaPMRSubscriber subcriber = creator.getDMaaPMRSubscriber();
58 DMaaPMRPublisher publisher = creator.getDMaaPMRPublisher();
60 // Create subscriber & publisher thread
61 Thread t1 = new Thread(new Runnable() {
65 LOGGER.debug("starting subscriber & publisher thread:{}", Thread.currentThread().getName());
66 dmaapService.fetchAndPublishInDMaaP(subcriber, publisher, creator);
67 } catch (InterruptedException e) {
68 LOGGER.error("Exception in starting of subscriber & publisher thread:{}",e);
69 Thread.currentThread().interrupt();
74 // Start subscriber & publisher thread
75 t1.setName("SNMP-COLLECTOR");
81 * method stops universal ves adapter module