activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r450451 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms: QueueBridge.java TopicBridge.java
Date Wed, 27 Sep 2006 14:19:45 GMT
Author: jstrachan
Date: Wed Sep 27 07:19:44 2006
New Revision: 450451

URL: http://svn.apache.org/viewvc?view=rev&rev=450451
Log:
ensure that producer & consumers are created lazily

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java?view=diff&rev=450451&r1=450450&r2=450451
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java
Wed Sep 27 07:19:44 2006
@@ -71,7 +71,7 @@
         return consumer;
     }
     
-    protected MessageProducer createProducer() throws JMSException{
+    protected synchronized MessageProducer createProducer() throws JMSException{
         producerSession=producerConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
         producer = producerSession.createSender(null);
         return producer;
@@ -80,7 +80,10 @@
         
         
     
-    protected void sendMessage(Message message) throws JMSException{
+    protected synchronized void sendMessage(Message message) throws JMSException{
+        if (producer == null) {
+            createProducer();
+        }
         producer.send(producerQueue,message);
     }
 

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java?view=diff&rev=450451&r1=450450&r2=450451
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java
Wed Sep 27 07:19:44 2006
@@ -79,13 +79,16 @@
     
     
     
-    protected MessageProducer createProducer() throws JMSException{
+    protected synchronized MessageProducer createProducer() throws JMSException{
         producerSession=producerConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
         producer = producerSession.createPublisher(null);
         return producer;
     }
     
-    protected void sendMessage(Message message) throws JMSException{
+    protected synchronized void sendMessage(Message message) throws JMSException{
+        if (producer == null) {
+            createProducer();
+        }
         producer.publish(producerTopic,message);
     }
 



Mime
View raw message