d1610305a63b395e51d1a650c98b84607ee08d61
[ccsdk/sli.git] /
1 /**\r
2  * ============LICENSE_START====================================================\r
3  * org.onap.aaf\r
4  * ===========================================================================\r
5  * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.\r
6  *\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
12  * \r
13  *      http://www.apache.org/licenses/LICENSE-2.0\r
14  * \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
21  *\r
22  */\r
23 \r
24 package org.onap.ccsdk.sli.adaptors.messagerouter.publisher.client.impl;\r
25 \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
29 \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
34         \r
35         public ClientImpl() {\r
36 \r
37         }\r
38 \r
39         public void setPublisher(PublisherApi publisherApi) {\r
40                 this.publisher = publisherApi;\r
41         }\r
42 \r
43         public void setTopic(String topic) {\r
44                 this.topic = topic;\r
45         }\r
46 \r
47         \r
48 \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
55                 }\r
56         }\r
57 \r
58 }