avoid creating new topic sessions each time
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/3ad59478 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/3ad59478 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/3ad59478 Branch: refs/heads/master Commit: 3ad594789e5858b74edb3f37db9ada61f1c0bfd4 Parents: a2986a5 Author: Nirmal Fernando <[email protected]> Authored: Wed Mar 26 15:09:02 2014 +0530 Committer: Nirmal Fernando <[email protected]> Committed: Wed Mar 26 15:09:02 2014 +0530 ---------------------------------------------------------------------- .../messaging/broker/publish/TopicPublisher.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3ad59478/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java index 7b380ee..6614e75 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java @@ -116,10 +116,14 @@ public class TopicPublisher extends MessagePublisher { if (topicSession != null && topicPublisher != null) { return; } - // initialize a TopicConnector - connector.init(getName()); - // get a session - topicSession = connector.newSession(); + + if (topicSession == null) { + // initialize a TopicConnector + connector.init(getName()); + // get a session + topicSession = connector.newSession(); + } + Topic topic = connector.getTopic(); if (topic == null) { // if the topic doesn't exist, create it.
