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 2021/03/03 16:40:21 UTC
[camel] branch master updated: CAMEL-16298: camel-core - pollEnrich
with endpoint-dsl should use EndpointConsumerBuilder
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 7507f55 CAMEL-16298: camel-core - pollEnrich with endpoint-dsl should use EndpointConsumerBuilder
7507f55 is described below
commit 7507f556c1bddffa9cc4249609fc96a4217865f2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 3 17:39:30 2021 +0100
CAMEL-16298: camel-core - pollEnrich with endpoint-dsl should use EndpointConsumerBuilder
---
.../camel/builder/EndpointConsumerBuilder.java | 12 ++++++++++
.../apache/camel/model/ProcessorDefinition.java | 21 ++++++++--------
...xpressionTest.java => AwsS3PollEnrichTest.java} | 28 ++++++++++------------
.../SedaPollEnrichSimpleExpressionTest.java | 4 +++-
4 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/builder/EndpointConsumerBuilder.java b/core/camel-core-model/src/main/java/org/apache/camel/builder/EndpointConsumerBuilder.java
index aef4f28..9a273ff 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/builder/EndpointConsumerBuilder.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/builder/EndpointConsumerBuilder.java
@@ -18,7 +18,9 @@ package org.apache.camel.builder;
import java.util.Map;
+import org.apache.camel.CamelContext;
import org.apache.camel.EndpointConsumerResolver;
+import org.apache.camel.Expression;
/**
* Type-safe endpoint DSL for building consumer endpoints.
@@ -46,4 +48,14 @@ public interface EndpointConsumerBuilder extends EndpointConsumerResolver {
*/
void doSetMultiValueProperties(String name, String prefix, Map<String, Object> values);
+ /**
+ * Builds an expression of this endpoint url. This API is only intended for Camel internally.
+ */
+ Expression expr();
+
+ /**
+ * Builds a dynamic expression of this endpoint url. This API is only intended for Camel internally.
+ */
+ Expression expr(CamelContext camelContext);
+
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 73413f8..25479ee 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -43,6 +43,7 @@ import org.apache.camel.LoggingLevel;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.builder.DataFormatClause;
+import org.apache.camel.builder.EndpointConsumerBuilder;
import org.apache.camel.builder.EndpointProducerBuilder;
import org.apache.camel.builder.EnrichClause;
import org.apache.camel.builder.ExpressionBuilder;
@@ -3176,7 +3177,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.PollEnricher
*/
- public Type pollEnrich(EndpointProducerBuilder resourceUri) {
+ public Type pollEnrich(EndpointConsumerBuilder resourceUri) {
return pollEnrich(resourceUri.expr(), -1, (String) null, false);
}
@@ -3196,7 +3197,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.PollEnricher
*/
- public Type pollEnrich(EndpointProducerBuilder resourceUri, AggregationStrategy aggregationStrategy) {
+ public Type pollEnrich(EndpointConsumerBuilder resourceUri, AggregationStrategy aggregationStrategy) {
return pollEnrich(resourceUri, -1, aggregationStrategy);
}
@@ -3218,7 +3219,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.PollEnricher
*/
- public Type pollEnrich(EndpointProducerBuilder resourceUri, long timeout, AggregationStrategy aggregationStrategy) {
+ public Type pollEnrich(EndpointConsumerBuilder resourceUri, long timeout, AggregationStrategy aggregationStrategy) {
return pollEnrich(resourceUri, timeout, aggregationStrategy, false);
}
@@ -3240,7 +3241,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.PollEnricher
*/
- public Type pollEnrich(EndpointProducerBuilder resourceUri, long timeout, String aggregationStrategyRef) {
+ public Type pollEnrich(EndpointConsumerBuilder resourceUri, long timeout, String aggregationStrategyRef) {
return pollEnrich(resourceUri, timeout, aggregationStrategyRef, false);
}
@@ -3279,7 +3280,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* additional data obtained from a <code>resourceUri</code> and with an aggregation strategy created using a fluent
* builder using a {@link org.apache.camel.PollingConsumer} to poll the endpoint.
*/
- public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(EndpointProducerBuilder resourceUri) {
+ public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(EndpointConsumerBuilder resourceUri) {
return pollEnrichWith(resourceUri, -1);
}
@@ -3288,7 +3289,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* additional data obtained from a <code>resourceUri</code> and with an aggregation strategy created using a fluent
* builder using a {@link org.apache.camel.PollingConsumer} to poll the endpoint.
*/
- public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(EndpointProducerBuilder resourceUri, long timeout) {
+ public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(EndpointConsumerBuilder resourceUri, long timeout) {
return pollEnrichWith(resourceUri, timeout, false);
}
@@ -3298,7 +3299,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* builder using a {@link org.apache.camel.PollingConsumer} to poll the endpoint.
*/
public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(
- EndpointProducerBuilder resourceUri, long timeout, boolean aggregateOnException) {
+ EndpointConsumerBuilder resourceUri, long timeout, boolean aggregateOnException) {
EnrichClause<ProcessorDefinition<Type>> clause = new EnrichClause<>(this);
pollEnrich(resourceUri, timeout, clause, aggregateOnException);
return clause;
@@ -3400,7 +3401,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @see org.apache.camel.processor.PollEnricher
*/
public Type pollEnrich(
- @AsEndpointUri EndpointProducerBuilder resourceUri, long timeout, AggregationStrategy aggregationStrategy,
+ @AsEndpointUri EndpointConsumerBuilder resourceUri, long timeout, AggregationStrategy aggregationStrategy,
boolean aggregateOnException) {
return pollEnrich(resourceUri.expr(), timeout, aggregationStrategy, aggregateOnException);
}
@@ -3427,7 +3428,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @see org.apache.camel.processor.PollEnricher
*/
public Type pollEnrich(
- @AsEndpointUri EndpointProducerBuilder resourceUri, long timeout, String aggregationStrategyRef,
+ @AsEndpointUri EndpointConsumerBuilder resourceUri, long timeout, String aggregationStrategyRef,
boolean aggregateOnException) {
return pollEnrich(resourceUri.expr(), timeout, aggregationStrategyRef, aggregateOnException);
}
@@ -3449,7 +3450,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.PollEnricher
*/
- public Type pollEnrich(@AsEndpointUri EndpointProducerBuilder resourceUri, long timeout) {
+ public Type pollEnrich(@AsEndpointUri EndpointConsumerBuilder resourceUri, long timeout) {
return pollEnrich(resourceUri, timeout, (String) null);
}
diff --git a/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/SedaPollEnrichSimpleExpressionTest.java b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/AwsS3PollEnrichTest.java
similarity index 60%
copy from core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/SedaPollEnrichSimpleExpressionTest.java
copy to core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/AwsS3PollEnrichTest.java
index 942986b..f944893 100644
--- a/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/SedaPollEnrichSimpleExpressionTest.java
+++ b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/AwsS3PollEnrichTest.java
@@ -16,31 +16,29 @@
*/
package org.apache.camel.builder.endpoint;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
-public class SedaPollEnrichSimpleExpressionTest extends CamelTestSupport {
+public class AwsS3PollEnrichTest extends CamelTestSupport {
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new EndpointRouteBuilder() {
- @Override
- public void configure() throws Exception {
- from(direct("start")).pollEnrich(seda("${exchangeProperty.whereFrom}").timeout(1000)).to("mock:result");
- }
- };
+ public boolean isUseRouteBuilder() {
+ return false;
}
@Test
public void test() throws Exception {
- MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
- resultEndpoint.expectedBodiesReceived("Hello World");
+ context.addRoutes(new EndpointRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .pollEnrich(aws2S3("test-bucket").fileName("${body}"))
+ .to("mock:result");
- template.sendBody("seda:cheese", "Hello World");
- template.sendBodyAndProperty("direct:start", "Empty", "whereFrom", "cheese");
+ }
+ });
+ context.start();
- assertMockEndpointsSatisfied();
+ context.stop();
}
}
diff --git a/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/SedaPollEnrichSimpleExpressionTest.java b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/SedaPollEnrichSimpleExpressionTest.java
index 942986b..beaefb8 100644
--- a/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/SedaPollEnrichSimpleExpressionTest.java
+++ b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/SedaPollEnrichSimpleExpressionTest.java
@@ -28,7 +28,9 @@ public class SedaPollEnrichSimpleExpressionTest extends CamelTestSupport {
return new EndpointRouteBuilder() {
@Override
public void configure() throws Exception {
- from(direct("start")).pollEnrich(seda("${exchangeProperty.whereFrom}").timeout(1000)).to("mock:result");
+ from(direct("start"))
+ .pollEnrich(seda("${exchangeProperty.whereFrom}").concurrentConsumers(1), 1000)
+ .to("mock:result");
}
};
}