HCATALOG-599 NotificationListener doesn't use getTopic() for sending messages.

git-svn-id: https://svn.apache.org/repos/asf/incubator/hcatalog/trunk@1438611 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index a04baa8..ce7d7ff 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -178,6 +178,8 @@
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-599 NotificationListener doesn't use getTopic() for sending messages. (mithun via traviscrawford)
+
   HCAT-605 HCatalog release script does not update version in build.properties (traviscrawford)
 
   HCAT-603 releaseaudit should run before generating artifacts (traviscrawford)
diff --git a/server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java b/server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java
index 0053b17..7551a27 100644
--- a/server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java
+++ b/server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java
@@ -254,7 +254,6 @@
      */
     protected void send(HCatEventMessage hCatEventMessage, String topicName) {
         try {
-            Destination topic = null;
             if(null == session){
                 // this will happen, if we never able to establish a connection.
                 createConnection();
@@ -265,17 +264,9 @@
                     return;
                 }
             }
-            try{
-                // Topics are created on demand. If it doesn't exist on broker it will
-                // be created when broker receives this message.
-                topic = session.createTopic(topicName);
-            } catch (IllegalStateException ise){
-                // this will happen if we were able to establish connection once, but its no longer valid,
-                // ise is thrown, catch it and retry.
-                LOG.error("Seems like connection is lost. Retrying", ise);
-                createConnection();
-                topic = session.createTopic(topicName);
-            }
+
+            Destination topic = getTopic(topicName);
+
             if (null == topic){
                 // Still not successful, return from here.
                 LOG.error("Invalid session. Failed to send message on topic: " +