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 public class SimpleExampleConsumer {
37 private static final Logger logger = LoggerFactory.getLogger(SimpleExampleConsumer.class);
39 public static void main(String[] args) {
42 long nextReport = 5000;
44 final long startMs = System.currentTimeMillis();
48 final MRConsumer cc = MRClientFactory.createConsumer("D:\\SG\\consumer.properties");
50 for (String msg : cc.fetch()) {
52 System.out.println("Message Received: " + msg);
54 // Header for DME2 Call.
55 MultivaluedMap<String, Object> headersMap = MRClientFactory.HTTPHeadersMap;
56 for (String key : headersMap.keySet()) {
57 System.out.println("Header Key " + key);
58 System.out.println("Header Value " + headersMap.get(key));
60 // Header for HTTP Call.
63 dme2headersMap=MRClientFactory.DME2HeadersMap; for(String key
64 : dme2headersMap.keySet()) { System.out.println("Header Key "
65 + key); System.out.println("Header Value " +
66 dme2headersMap.get(key)); }
68 if (count > nextReport) {
71 final long endMs = System.currentTimeMillis();
72 final long elapsedMs = endMs - startMs;
73 final double elapsedSec = elapsedMs / 1000.0;
74 final double eps = count / elapsedSec;
75 System.out.println("Consumed " + count + " in " + elapsedSec + "; " + eps + " eps");
78 } catch (Exception x) {
79 System.err.println(x.getClass().getName() + ": " + x.getMessage());
80 logger.error("exception: ", x);