2 * ============LICENSE_START====================================================
\r
4 * ===========================================================================
\r
5 * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
\r
7 * Modifications Copyright (C) 2019 IBM.
\r
8 * ===========================================================================
\r
9 * Licensed under the Apache License, Version 2.0 (the "License");
\r
10 * you may not use this file except in compliance with the License.
\r
11 * You may obtain a copy of the License at
\r
13 * http://www.apache.org/licenses/LICENSE-2.0
\r
15 * Unless required by applicable law or agreed to in writing, software
\r
16 * distributed under the License is distributed on an "AS IS" BASIS,
\r
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
18 * See the License for the specific language governing permissions and
\r
19 * limitations under the License.
\r
20 * ============LICENSE_END====================================================
\r
24 package org.onap.ccsdk.sli.adaptors.messagerouter.publisher.client.impl;
\r
26 import org.onap.ccsdk.sli.adaptors.messagerouter.publisher.api.PublisherApi;
\r
27 import org.slf4j.Logger;
\r
28 import org.slf4j.LoggerFactory;
\r
30 public class ClientImpl {
\r
31 private static final Logger logger = LoggerFactory.getLogger(ClientImpl.class);
\r
32 private String topic;
\r
33 private PublisherApi publisher;
\r
35 public ClientImpl() {
\r
39 public void setPublisher(PublisherApi publisherApi) {
\r
40 this.publisher = publisherApi;
\r
43 public void setTopic(String topic) {
\r
49 public void init() {
\r
50 for (int i = 0; i < 5; i++) {
\r
51 String body = "{\"hello\":\"world " + Math.random() + "\"}";
\r
52 logger.error("Loop iteration " + i + " sending body " + body + " to the topic " + topic);
\r
53 Boolean result = publisher.publish(topic, body);
\r
54 logger.error("Loop iteration " + i + " returned the boolean value " + result);
\r