From 38280dcce5a2d489c3e016d531faf043dbaddb41 Mon Sep 17 00:00:00 2001 From: Ryan Young Date: Wed, 30 May 2018 14:10:10 -0400 Subject: Refactor properties used for topic names Change-Id: Ifc7e5c0c57f64a237c2314ba7a60dabb92e067f1 Signed-off-by: Ryan Young Issue-ID: APPC-934 --- .../client/impl/protocol/UEBMessagingService.java | 38 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'appc-client/client-lib') diff --git a/appc-client/client-lib/src/main/java/org/onap/appc/client/impl/protocol/UEBMessagingService.java b/appc-client/client-lib/src/main/java/org/onap/appc/client/impl/protocol/UEBMessagingService.java index 0a9e1a630..ed0ee5480 100644 --- a/appc-client/client-lib/src/main/java/org/onap/appc/client/impl/protocol/UEBMessagingService.java +++ b/appc-client/client-lib/src/main/java/org/onap/appc/client/impl/protocol/UEBMessagingService.java @@ -41,6 +41,8 @@ class UEBMessagingService implements MessagingService { private static final String DEFAULT_READ_TIMEOUT_MS = "60000"; private static final String DEFAULT_READ_LIMIT = "1000"; + private static final String DEFAULT_READ_TOPIC = "client-read"; + private static final String DEFAULT_WRITE_TOPIC = "client-write"; private Consumer consumer; private Producer producer; @@ -52,14 +54,40 @@ class UEBMessagingService implements MessagingService { throws IOException, GeneralSecurityException, NoSuchFieldException, IllegalAccessException { if (props != null) { - String readTopic = props.getProperty(UEBPropertiesKeys.TOPIC_READ); - String writeTopic = props.getProperty(UEBPropertiesKeys.TOPIC_WRITE); - String cType = props.getProperty(UEBPropertiesKeys.CONTROLLER_TYPE); + String readTopic = null; + String writeTopic = null; + String cType = props.getProperty(UEBPropertiesKeys.CONTROLLER_TYPE); //CONTROLLER_TYPE = "controllerType" + if (cType != null && cType.length()!= 0 && (!cType.equals("APPC"))) { - readTopic = cType + "-" + readTopic; - writeTopic = cType + "-" + writeTopic; + logger.debug("Using controller type " + cType + " for topic properties"); + + readTopic = props.getProperty(cType + "-" + UEBPropertiesKeys.TOPIC_READ); + if(readTopic == null) { + logger.error("Error reading property '"+ cType + "-" + UEBPropertiesKeys.TOPIC_READ + "' defaulting to " + DEFAULT_READ_TOPIC); + readTopic = DEFAULT_READ_TOPIC; + } + writeTopic = props.getProperty(cType + "-" + UEBPropertiesKeys.TOPIC_WRITE); + if(writeTopic == null) { + logger.error("Error reading property '"+ cType + "-" + UEBPropertiesKeys.TOPIC_READ + "' defaulting to " + DEFAULT_WRITE_TOPIC); + writeTopic = DEFAULT_WRITE_TOPIC; + } } + else { + readTopic = props.getProperty(UEBPropertiesKeys.TOPIC_READ); //TOPIC_READ = "topic.read" + if(readTopic == null) { + logger.error("Error reading property '"+ UEBPropertiesKeys.TOPIC_READ + "' defaulting to " + DEFAULT_READ_TOPIC); + readTopic = DEFAULT_READ_TOPIC; + } + writeTopic = props.getProperty(UEBPropertiesKeys.TOPIC_WRITE); //TOPIC_WRITE = "topic.write" + if(writeTopic == null) { + logger.error("Error reading property '" + UEBPropertiesKeys.TOPIC_READ + "' defaulting to " + DEFAULT_WRITE_TOPIC); + writeTopic = DEFAULT_WRITE_TOPIC; + } + } + + logger.debug("Using topics: Read = '" + readTopic + "' Write = '" + writeTopic + "'"); + String apiKey = props.getProperty(UEBPropertiesKeys.AUTH_USER); String apiSecret = props.getProperty(UEBPropertiesKeys.AUTH_SECRET); String readTimeoutString = props.getProperty(UEBPropertiesKeys.TOPIC_READ_TIMEOUT, DEFAULT_READ_TIMEOUT_MS); -- cgit 1.2.3-korg