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 2019/01/22 15:20:58 UTC
[camel] branch master updated: camel3 - browse component should use
public camel-api
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 6c32421 camel3 - browse component should use public camel-api
6c32421 is described below
commit 6c32421f1f6ec9063fe51a63fe0635763445be4a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jan 22 16:19:52 2019 +0100
camel3 - browse component should use public camel-api
---
.../camel/component/browse/BrowseEndpoint.java | 16 ++++---
.../component/browse/BrowseRouteConsumeTest.java | 53 ++++++++++++++++++++++
2 files changed, 62 insertions(+), 7 deletions(-)
diff --git a/camel-core/src/main/java/org/apache/camel/component/browse/BrowseEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/browse/BrowseEndpoint.java
index d2b7430..6738654 100644
--- a/camel-core/src/main/java/org/apache/camel/component/browse/BrowseEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/browse/BrowseEndpoint.java
@@ -24,13 +24,11 @@ import org.apache.camel.Consumer;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
-import org.apache.camel.processor.loadbalancer.LoadBalancer;
-import org.apache.camel.processor.loadbalancer.LoadBalancerConsumer;
-import org.apache.camel.processor.loadbalancer.TopicLoadBalancer;
import org.apache.camel.spi.BrowsableEndpoint;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultConsumer;
import org.apache.camel.support.DefaultEndpoint;
import org.apache.camel.support.DefaultProducer;
@@ -46,7 +44,7 @@ public class BrowseEndpoint extends DefaultEndpoint implements BrowsableEndpoint
private String name;
private List<Exchange> exchanges;
- private final LoadBalancer loadBalancer = new TopicLoadBalancer();
+ private volatile Processor onExchangeProcessor;
public BrowseEndpoint() {
}
@@ -75,7 +73,9 @@ public class BrowseEndpoint extends DefaultEndpoint implements BrowsableEndpoint
}
public Consumer createConsumer(Processor processor) throws Exception {
- Consumer answer = new LoadBalancerConsumer(this, processor, loadBalancer);
+ this.onExchangeProcessor = processor;
+
+ Consumer answer = new DefaultConsumer(this, processor);
configureConsumer(answer);
return answer;
}
@@ -101,8 +101,10 @@ public class BrowseEndpoint extends DefaultEndpoint implements BrowsableEndpoint
protected void onExchange(Exchange exchange) throws Exception {
getExchanges().add(exchange);
- // now fire any consumers
- loadBalancer.process(exchange);
+ // now fire the consumer
+ if (onExchangeProcessor != null) {
+ onExchangeProcessor.process(exchange);
+ }
}
@Override
diff --git a/camel-core/src/test/java/org/apache/camel/component/browse/BrowseRouteConsumeTest.java b/camel-core/src/test/java/org/apache/camel/component/browse/BrowseRouteConsumeTest.java
new file mode 100644
index 0000000..23ac082
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/browse/BrowseRouteConsumeTest.java
@@ -0,0 +1,53 @@
+/**
+ * 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.component.browse;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spi.BrowsableEndpoint;
+import org.junit.Test;
+
+public class BrowseRouteConsumeTest extends ContextTestSupport {
+
+ @Test
+ public void testBrowseRoute() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:foo");
+ mock.expectedBodiesReceived("Hello World", "Bye World");
+
+ template.sendBody("direct:start", "Hello World");
+ template.sendBody("direct:start", "Bye World");
+
+ assertMockEndpointsSatisfied();
+
+ BrowsableEndpoint list = context.getEndpoint("browse:foo", BrowsableEndpoint.class);
+
+ mock.getExchanges().get(0).equals(list.getExchanges().get(0));
+ mock.getExchanges().get(1).equals(list.getExchanges().get(1));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("direct:start").to("browse:foo").to("mock:result");
+
+ from("browse:foo").to("log:foo").to("mock:foo");
+ }
+ };
+ }
+}
\ No newline at end of file