You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/08/03 09:45:42 UTC
[2/3] git commit: CAMEL-6604: Fixed routing slip and dynamic router
EIP to work with stream caching properly.
CAMEL-6604: Fixed routing slip and dynamic router 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/2c6e0e50
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2c6e0e50
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2c6e0e50
Branch: refs/heads/camel-2.11.x
Commit: 2c6e0e501252dc8d3beb4830ee9247ab0ef3d0f0
Parents: 0470015
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Aug 3 09:37:07 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Aug 3 09:38:15 2013 +0200
----------------------------------------------------------------------
.../org/apache/camel/processor/RoutingSlip.java | 5 ++
.../processor/StreamCachingRoutingSlipTest.java | 49 ++++++++++++++++++++
2 files changed, 54 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2c6e0e50/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java b/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
index 5a50f4e..dfb4ecd 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
@@ -36,6 +36,7 @@ import org.apache.camel.impl.ProducerCache;
import org.apache.camel.support.ServiceSupport;
import org.apache.camel.util.AsyncProcessorHelper;
import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.MessageHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.ServiceHelper;
import org.slf4j.Logger;
@@ -268,6 +269,10 @@ public class RoutingSlip extends ServiceSupport implements AsyncProcessor, Trace
// exchange being routed.
copy.setExchangeId(current.getExchangeId());
copyOutToIn(copy, current);
+
+ // ensure stream caching is reset
+ MessageHelper.resetStreamCache(copy.getIn());
+
return copy;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/2c6e0e50/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRoutingSlipTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRoutingSlipTest.java b/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRoutingSlipTest.java
new file mode 100644
index 0000000..9a0909b
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRoutingSlipTest.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 StreamCachingRoutingSlipTest 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")
+ .routingSlip(header("mySlip"));
+ }
+ };
+ }
+}
+