Repository: incubator-stratos Updated Branches: refs/heads/master 4ae2f2b15 -> 52d9b232c
avoiding creating new connections to MB always. this could fix https://issues.apache.org/jira/browse/STRATOS-593 too Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/6f7b2191 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/6f7b2191 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/6f7b2191 Branch: refs/heads/master Commit: 6f7b21918e527147ebae37c2756627e963d59847 Parents: 819701d Author: Nirmal Fernando <[email protected]> Authored: Wed Apr 9 17:47:09 2014 +0530 Committer: Nirmal Fernando <[email protected]> Committed: Wed Apr 9 17:47:09 2014 +0530 ---------------------------------------------------------------------- .../messaging/broker/subscribe/TopicSubscriber.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6f7b2191/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java index f5ba8e9..f6fa587 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java @@ -56,10 +56,17 @@ public class TopicSubscriber implements Runnable { } private void doSubscribe() throws Exception, JMSException { - // initialize a TopicConnector - connector.init(topicName); - // get a session - topicSession = connector.newSession(); + if (topicSession != null && topicSubscriber != null) { + return; + } + + if (topicSession == null) { + // initialize a TopicConnector + connector.init(topicName); + // get a session + topicSession = connector.newSession(); + } + Topic topic = connector.getTopic(); if (topic == null) { // if topic doesn't exist, create it.
