From 0137a3023fadcd666cc8bcb7d85916c304c56de8 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Wed, 21 Dec 2011 12:49:32 -0500 Subject: [PATCH] INT-2327-v2 polishing fixed the initialization routine to perform only once --- .../jms/SubscribableJmsChannel.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/SubscribableJmsChannel.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/SubscribableJmsChannel.java index f63d5c0c59..e14c140341 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/SubscribableJmsChannel.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/SubscribableJmsChannel.java @@ -46,6 +46,8 @@ public class SubscribableJmsChannel extends AbstractJmsChannel implements Subscr private volatile MessageDispatcher dispatcher; + private volatile boolean initialized; + public SubscribableJmsChannel(AbstractMessageListenerContainer container, JmsTemplate jmsTemplate) { super(jmsTemplate); Assert.notNull(container, "container must not be null"); @@ -65,17 +67,17 @@ public class SubscribableJmsChannel extends AbstractJmsChannel implements Subscr @Override public void onInit() throws Exception { - synchronized (this.dispatcher) { - if (this.dispatcher == null){ - super.onInit(); - this.configureDispatcher(this.container.isPubSubDomain()); - MessageListener listener = new DispatchingMessageListener(this.getJmsTemplate(), this.dispatcher); - this.container.setMessageListener(listener); - if (!this.container.isActive()) { - this.container.afterPropertiesSet(); - } - } + if (this.initialized){ + return; } + super.onInit(); + this.configureDispatcher(this.container.isPubSubDomain()); + MessageListener listener = new DispatchingMessageListener(this.getJmsTemplate(), this.dispatcher); + this.container.setMessageListener(listener); + if (!this.container.isActive()) { + this.container.afterPropertiesSet(); + } + this.initialized = true; } private void configureDispatcher(boolean isPubSub) {