Author: davsclaus
Date: Fri Oct  5 08:42:10 2012
New Revision: 1394408

URL: http://svn.apache.org/viewvc?rev=1394408&view=rev
Log:
CAMEL-5683: SendProcessor should not use a soft cache as we want the producer 
to be kept around, as we only store a single producer. This prevents the 
producer to be GC when running low on memory, that can cause Camel JMS 
component using temporary queues with request/reply to create new producer, and 
not re-use existing. Causing a leak for message listeners over time.

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java?rev=1394408&r1=1394407&r2=1394408&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java 
(original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java 
Fri Oct  5 08:42:10 2012
@@ -64,6 +64,10 @@ public class ProducerCache extends Servi
         this(source, camelContext, camelContext.getProducerServicePool(), 
createLRUCache(cacheSize));
     }
 
+    public ProducerCache(Object source, CamelContext camelContext, Map<String, 
Producer> cache) {
+        this(source, camelContext, camelContext.getProducerServicePool(), 
cache);
+    }
+
     public ProducerCache(Object source, CamelContext camelContext, 
ServicePool<Endpoint, Producer> producerServicePool, Map<String, Producer> 
cache) {
         this.source = source;
         this.camelContext = camelContext;

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java?rev=1394408&r1=1394407&r2=1394408&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AsyncProcessorTypeConverter.java
 Fri Oct  5 08:42:10 2012
@@ -44,7 +44,7 @@ public class AsyncProcessorTypeConverter
     }
 
     /**
-     * @deprecated use AnycProcessorConverter.convert instead
+     * @deprecated use {@link 
AsyncProcessorConverterHelper#convert(org.apache.camel.Processor)} instead
      */
     @Deprecated
     public static AsyncProcessor convert(Processor value) {

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java?rev=1394408&r1=1394407&r2=1394408&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
 Fri Oct  5 08:42:10 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.processor;
 
+import java.util.HashMap;
+
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.AsyncProcessor;
 import org.apache.camel.AsyncProducerCallback;
@@ -149,7 +151,10 @@ public class SendProcessor extends Servi
     protected void doStart() throws Exception {
         if (producerCache == null) {
             // use a single producer cache as we need to only hold reference 
for one destination
-            producerCache = new ProducerCache(this, camelContext, 1);
+            // and use a regular HashMap as we do not want a soft reference 
store that may get re-claimed when low on memory
+            // as we want to ensure the producer is kept around, to ensure its 
lifecycle is fully managed,
+            // eg stopping the producer when we stop etc.
+            producerCache = new ProducerCache(this, camelContext, new 
HashMap<String, Producer>(1));
             // do not add as service as we do not want to manage the producer 
cache
         }
         ServiceHelper.startService(producerCache);


Reply via email to