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
11 * http://www.apache.org/licenses/LICENSE-2.0
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===========================================
21 package org.onap.dcae.apod.analytics.dmaap.service.publisher;
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;
27 import java.util.Date;
28 import java.util.List;
32 * DMaaP MR Publisher can be used to publish messages to DMaaP MR Topics.
35 * @author Rajiv Singla . Creation Date: 10/13/2016.
37 public interface DMaaPMRPublisher extends AutoCloseable {
42 * Adds collection of messages to DMaaP MR Topic Publishing Queue.
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.
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}
56 DMaaPMRPublisherResponse publish(List<String> messages);
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.
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
70 DMaaPMRPublisherResponse forcePublish(List<String> messages);
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
80 * @return DMaaP Message Router Publisher Response
82 DMaaPMRPublisherResponse flush();
87 * Returns the creation time when Publisher instance was created.
90 * @return creation time of Subscriber instance
92 Date getPublisherCreationTime();