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