Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-dmaap / src / main / java / org / openecomp / dcae / apod / analytics / dmaap / service / publisher / DMaaPMRPublisher.java
1 /*\r
2  * ===============================LICENSE_START======================================\r
3  *  dcae-analytics\r
4  * ================================================================================\r
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  *  Licensed under the Apache License, Version 2.0 (the "License");\r
8  *  you may not use this file except in compliance with the License.\r
9  *   You may obtain a copy of the License at\r
10  *\r
11  *          http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  *  Unless required by applicable law or agreed to in writing, software\r
14  *  distributed under the License is distributed on an "AS IS" BASIS,\r
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  *  See the License for the specific language governing permissions and\r
17  *  limitations under the License.\r
18  *  ============================LICENSE_END===========================================\r
19  */\r
20 \r
21 package org.openecomp.dcae.apod.analytics.dmaap.service.publisher;\r
22 \r
23 import org.openecomp.dcae.apod.analytics.common.exception.DCAEAnalyticsRuntimeException;\r
24 import org.openecomp.dcae.apod.analytics.dmaap.domain.config.DMaaPMRPublisherConfig;\r
25 import org.openecomp.dcae.apod.analytics.dmaap.domain.response.DMaaPMRPublisherResponse;\r
26 \r
27 import java.util.Date;\r
28 import java.util.List;\r
29 \r
30 /**\r
31  * <p>\r
32  *     DMaaP MR Publisher can be used to publish messages to DMaaP MR Topics.\r
33  * <p>\r
34  *\r
35  * @author Rajiv Singla . Creation Date: 10/13/2016.\r
36  */\r
37 public interface DMaaPMRPublisher extends AutoCloseable {\r
38 \r
39 \r
40     /**\r
41      * <p>\r
42      *     Adds collection of messages to DMaaP MR Topic Publishing Queue.\r
43      * <p>\r
44      *     Note: Invoking this method may or may not cause publishing immediately\r
45      *     as publishing in done is batch mode by default. Parameter maxBatchSize\r
46      *     in {@link DMaaPMRPublisherConfig} is used to determine max batch queue size.\r
47      *     If the maxBatchSize is reached all message will be published automatically\r
48      *     during subsequent call.\r
49      * </p>\r
50      *\r
51      * @param messages messages to publish to DMaaP MR Publisher\r
52      * @return response which may contain Http Response code 202 (Accepted) as publishing\r
53      * will proceed when max batch size is reached. Throws {@link DCAEAnalyticsRuntimeException}\r
54      * if publishing fails\r
55      */\r
56     DMaaPMRPublisherResponse publish(List<String> messages);\r
57 \r
58 \r
59     /**\r
60      * <p>\r
61      *     Forces publishing of messages to DMaaP MR Topic and returns {@link DMaaPMRPublisherResponse}\r
62      *     which can be inspected for HTTP status code of publishing call to DMaaP MR Topic.\r
63      * </p>\r
64      *\r
65      * @param messages messages to publish to DMaaP MR Publisher\r
66      * @return DMaaP Message Router Publisher Response. Throws {@link DCAEAnalyticsRuntimeException}\r
67      * if force publishing fails\r
68      *\r
69      */\r
70     DMaaPMRPublisherResponse forcePublish(List<String> messages);\r
71 \r
72 \r
73     /**\r
74      * <p>\r
75      *     Forces publishing of messages in Publisher queue to DMaaP MR Topic and returns\r
76      *     {@link DMaaPMRPublisherResponse}.If there are no messages were in the queue to\r
77      *     be flushed response code 304 (Not Modified) will be returned\r
78      * </p>\r
79      *\r
80      * @return DMaaP Message Router Publisher Response\r
81      */\r
82     DMaaPMRPublisherResponse flush();\r
83 \r
84 \r
85     /**\r
86      * <p>\r
87      *     Returns the creation time when Publisher instance was created.\r
88      * <p>\r
89      *\r
90      * @return creation time of Subscriber instance\r
91      */\r
92     Date getPublisherCreationTime();\r
93 \r
94 \r
95 }\r