2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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.openecomp.portalapp.uebhandler;
23 import java.util.concurrent.ConcurrentLinkedQueue;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.scheduling.annotation.Async;
27 import org.springframework.stereotype.Component;
29 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
30 import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
31 import org.openecomp.portalsdk.core.onboarding.ueb.UebMsgTypes;
33 //-------------------------------------------------------------------------
34 // Listens for received UEB messages and handles the messages
36 // Note: To implement a synchronous reply call getMsgId on the request
37 // and putMsgId on the reply (echoing the request MsgId).
40 * The Class MainUebHandler.
42 //-------------------------------------------------------------------------
43 @Component("MainUebHandler")
44 public class MainUebHandler {
47 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MainUebHandler.class);
50 /** The inbox queue. */
51 ConcurrentLinkedQueue<UebMsg> inboxQueue = null;
53 /** The widget notification handler. */
55 WidgetNotificationHandler widgetNotificationHandler;
60 * @param queue the queue
63 public void runHandler(ConcurrentLinkedQueue<UebMsg> queue) {
66 logger.info(EELFLoggerDelegate.debugLogger, ("==> MainUebHandler started"));
70 while ((msg = inboxQueue.poll()) != null) {
71 if (msg.getMsgType() != null) {
72 logger.debug(EELFLoggerDelegate.debugLogger, ("<== Received UEB message : " + msg.toString()));
74 switch (msg.getMsgType()) {
76 * Add your own defined handler objects, use @Component for
77 * the class. See WidgetNotificationHandler as an example.
79 * Use @Async on methods for performance
81 * For syncronous replies use UebManager publishReply and
82 * echo back the msgId in your response ie
83 * msg.putMsgId(requestMsg.getMsgId())
85 * case UebMsgTypes.UEB_MSG_TYPE_XYZ: {
86 * XYZHandler.handleMsg(msg); break; }
88 case UebMsgTypes.UEB_MSG_TYPE_WIDGET_NOTIFICATION: {
89 widgetNotificationHandler.handleWidgetNotification(msg);
94 logger.info(EELFLoggerDelegate.debugLogger, ("Unknown message type [" + msg.getMsgType() + "] from " + msg.getSourceTopicName()));
102 if (Thread.interrupted()) {
104 logger.info(EELFLoggerDelegate.debugLogger, ("==> UebMainHandler exiting"));
111 } catch (InterruptedException e) {
112 logger.info(EELFLoggerDelegate.debugLogger, ("UebMainHandler interrupted during sleep" + e.getMessage()));