b86513618a98d269f335c53e2f1f784c72995ba5
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright (C) 2017 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22
23 package org.openecomp.appc.listener;
24
25 /**
26  * This interface defines a listener that subscribes to a DMaaP topic and continually polls for messages. The
27  * listener does all operations in the run() method and long running operations should be created in a separate worker
28  * thread.
29  *
30  */
31 public interface Listener extends Runnable {
32
33     /**
34      * Should start a continuous poll to get messages from the message bus only ending when stop() or stopNow() are
35      * called.
36      * 
37      * @see java.lang.Runnable#run()
38      */
39     @Override
40     public void run();
41
42     /**
43      * Signals the listener to stop accepting new messages to the queue and to cleanly finish processing all remaining
44      * messages in the queue. This can take a significant amount of time to complete depending on the thread pool
45      * characteristics. Similar to {@link #stopNow()}
46      */
47     public void stop();
48
49     /**
50      * Signals the listener to stop accepting new messages to the queue and to destroy all remaining messages in the
51      * queue. This will complete quicker than {@link #stop()} at the cost of discarded requests. Recovery of these
52      * requests would have to be caught downstream. Similar to {@link #stop()}
53      */
54     public void stopNow();
55
56     /**
57      * @return A string that shows various benchmarking data. Can be used by humans to tune the thread pool.
58      */
59     public String getBenchmark();
60
61     /**
62      * @return The listener's id when requesting messages from DMaaP. Also known as the group id.
63      */
64     public String getListenerId();
65
66     /**
67      * Sets the listener's id to use when requesting messages from DMaaP. Also known as the group id.
68      * 
69      * @param idString
70      *            The new listener id
71      */
72     public void setListenerId(String idString);
73 }