diff options
author | Ryan Young <ry303t@att.com> | 2018-05-30 14:10:10 -0400 |
---|---|---|
committer | Patrick Brady <pb071s@att.com> | 2018-05-30 18:41:23 +0000 |
commit | dab1dcf0bdb0cf4deca8617be240320af7e85f73 (patch) | |
tree | b5b10aabc434cd0075dc8b38b84d3b211461a80c | |
parent | 27e0cae126ee222e1c45f9942a77d79b424e32a2 (diff) |
Refactor properties used for topic names
Change-Id: Ifc7e5c0c57f64a237c2314ba7a60dabb92e067f1
Signed-off-by: Ryan Young <ry303t@att.com>
Issue-ID: APPC-934
(cherry picked from commit 38280dcce5a2d489c3e016d531faf043dbaddb41)
-rw-r--r-- | appc-client/client-lib/src/main/java/org/onap/appc/client/impl/protocol/UEBMessagingService.java | 38 |
1 files changed, 33 insertions, 5 deletions
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); |