1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 *******************************************************************************/
23 package com.att.nsa.mr.dme.client;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 import javax.ws.rs.core.MultivaluedMap;
32 import com.att.nsa.mr.client.MRClientFactory;
33 import com.att.nsa.mr.client.MRConsumer;
35 import java.util.List;
37 public class SimpleExampleConsumer {
39 private static final Logger logger = LoggerFactory.getLogger(SimpleExampleConsumer.class);
41 private SimpleExampleConsumer() {
44 public static void main(String[] args) {
47 long nextReport = 5000;
50 final long startMs = System.currentTimeMillis();
54 final MRConsumer cc = MRClientFactory.createConsumer("D:\\SG\\consumer.properties");
56 for (String msg : cc.fetch()) {
57 logger.debug("Message Received: " + msg);
59 // Header for DME2 Call.
60 MultivaluedMap<String, Object> headersMap = MRClientFactory.HTTPHeadersMap;
61 for (MultivaluedMap.Entry<String, List<Object>> entry : headersMap.entrySet()) {
63 logger.debug("Header Key " + key);
64 logger.debug("Header Value " + headersMap.get(key));
66 // Header for HTTP Call.
68 Map<String, String> dme2headersMap = MRClientFactory.DME2HeadersMap;
69 for (Map.Entry<String, String> entry : dme2headersMap.entrySet()) {
71 logger.debug("Header Key " + key);
72 logger.debug("Header Value " + dme2headersMap.get(key));
75 if (count > nextReport) {
78 final long endMs = System.currentTimeMillis();
79 final long elapsedMs = endMs - startMs;
80 final double elapsedSec = elapsedMs / 1000.0;
81 final double eps = count / elapsedSec;
84 } catch (Exception x) {
85 logger.error(x.toString());