camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: CAMEL-6604: Fixed recipient list EIP to work with stream caching properly.
Date Mon, 05 Aug 2013 10:00:39 GMT
Updated Branches:
  refs/heads/master 62e295e10 -> 4209fabb6


CAMEL-6604: Fixed recipient list EIP to work with stream caching properly.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4209fabb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4209fabb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4209fabb

Branch: refs/heads/master
Commit: 4209fabb6abade9d02f5cd382c089a14f5800b59
Parents: 62e295e
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Aug 5 11:57:06 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Aug 5 11:57:06 2013 +0200

----------------------------------------------------------------------
 .../camel/processor/RecipientListProcessor.java |  3 ++
 .../StreamCachingRecipientListTest.java         | 49 ++++++++++++++++++++
 2 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4209fabb/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
b/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
index 92b3422..9a9bf91 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
@@ -30,6 +30,7 @@ import org.apache.camel.impl.ProducerCache;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.MessageHelper;
 import org.apache.camel.util.ServiceHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -100,6 +101,8 @@ public class RecipientListProcessor extends MulticastProcessor {
             // we have already acquired and prepare the producer
             LOG.trace("RecipientProcessorExchangePair #{} begin: {}", index, exchange);
             exchange.setProperty(Exchange.RECIPIENT_LIST_ENDPOINT, endpoint.getEndpointUri());
+            // ensure stream caching is reset
+            MessageHelper.resetStreamCache(exchange.getIn());
         }
 
         public void done() {

http://git-wip-us.apache.org/repos/asf/camel/blob/4209fabb/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRecipientListTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRecipientListTest.java
b/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRecipientListTest.java
new file mode 100644
index 0000000..373e3e4
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRecipientListTest.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class StreamCachingRecipientListTest extends ContextTestSupport {
+
+    public void testByteArrayInputStream() throws Exception {
+        getMockEndpoint("mock:foo").expectedBodiesReceived("<hello/>");
+        getMockEndpoint("mock:bar").expectedBodiesReceived("<hello/>");
+        getMockEndpoint("mock:baz").expectedBodiesReceived("<hello/>");
+
+        template.sendBodyAndHeader("direct:a", new ByteArrayInputStream("<hello/>".getBytes()),
"mySlip", "mock:foo,mock:bar,mock:baz");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                context.setStreamCaching(true);
+
+                from("direct:a")
+                    .recipientList(header("mySlip"));
+            }
+        };
+    }
+}
+


Mime
View raw message