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 2023/07/29 12:01:47 UTC

[camel] branch main updated: Poll (#10900)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 36a568640b2 Poll (#10900)
36a568640b2 is described below

commit 36a568640b2a3d00c306731280886e85e8c082ec
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jul 29 14:01:41 2023 +0200

    Poll (#10900)
    
    * Deprecated some unusued exchange constants
    
    * CAMEL-19682: camel-core - Poll Enrich EIP should set TO_ENDPOINT as exchange property and not header
---
 .../src/main/java/org/apache/camel/Exchange.java   |  4 ++
 .../org/apache/camel/processor/PollEnricher.java   |  6 +-
 .../enricher/PollEnricherNoResourceTest.java       | 18 +++--
 .../camel/processor/enricher/PollEnricherTest.java |  6 +-
 .../apache/camel/support/HealthCheckComponent.java |  6 +-
 .../ROOT/pages/camel-4-migration-guide.adoc        | 82 ++++++++++++----------
 6 files changed, 69 insertions(+), 53 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/Exchange.java b/core/camel-api/src/main/java/org/apache/camel/Exchange.java
index 2f69e1adc25..0db1ae54850 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Exchange.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Exchange.java
@@ -247,9 +247,13 @@ public interface Exchange {
     String TIMER_PERIOD = "CamelTimerPeriod";
     String TIMER_TIME = "CamelTimerTime";
     String TO_ENDPOINT = "CamelToEndpoint";
+    @Deprecated
     String TRACE_EVENT = "CamelTraceEvent";
+    @Deprecated
     String TRACE_EVENT_NODE_ID = "CamelTraceEventNodeId";
+    @Deprecated
     String TRACE_EVENT_TIMESTAMP = "CamelTraceEventTimestamp";
+    @Deprecated
     String TRACE_EVENT_EXCHANGE = "CamelTraceEventExchange";
     @Deprecated
     String TRACING_HEADER_FORMAT = "CamelTracingHeaderFormat";
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/PollEnricher.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/PollEnricher.java
index 0a5cb044554..99e9c6734af 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/PollEnricher.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/PollEnricher.java
@@ -24,6 +24,7 @@ import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePropertyKey;
 import org.apache.camel.Expression;
 import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.NoTypeConversionAvailableException;
@@ -335,8 +336,9 @@ public class PollEnricher extends AsyncProcessorSupport implements IdAware, Rout
                 }
             }
 
-            // set header with the uri of the endpoint enriched so we can use that for tracing etc
-            exchange.getMessage().setHeader(Exchange.TO_ENDPOINT, consumer.getEndpoint().getEndpointUri());
+            // set property with the uri of the endpoint enriched so we can use that for tracing etc
+            exchange.setProperty(ExchangePropertyKey.TO_ENDPOINT, consumer.getEndpoint().getEndpointUri());
+
         } catch (Throwable e) {
             exchange.setException(new CamelExchangeException("Error occurred during aggregation", exchange, e));
             callback.done(true);
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java
index 3d10e124682..8fa20539734 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.processor.enricher;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
 public class PollEnricherNoResourceTest extends ContextTestSupport {
@@ -28,7 +29,6 @@ public class PollEnricherNoResourceTest extends ContextTestSupport {
         // there should be no message body
         getMockEndpoint("mock:result").expectedMessageCount(1);
         getMockEndpoint("mock:result").message(0).body().isNull();
-        getMockEndpoint("mock:result").expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://foo");
 
         template.sendBody("direct:a", "Hello World");
 
@@ -43,7 +43,6 @@ public class PollEnricherNoResourceTest extends ContextTestSupport {
 
         // there should be a message body
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-        getMockEndpoint("mock:result").expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://foo");
 
         template.sendBody("direct:a", "Hello World");
 
@@ -56,7 +55,6 @@ public class PollEnricherNoResourceTest extends ContextTestSupport {
 
         // there should be a message body
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-        getMockEndpoint("mock:result").expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://bar");
 
         template.sendBody("direct:b", "Hello World");
 
@@ -67,9 +65,17 @@ public class PollEnricherNoResourceTest extends ContextTestSupport {
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("direct:a").pollEnrich("seda:foo", 1000).to("mock:result");
-
-                from("direct:b").pollEnrich("seda:bar").to("mock:result");
+                from("direct:a").pollEnrich("seda:foo", 1000)
+                        .process(e -> {
+                            Assertions.assertEquals("seda://foo", e.getProperty(Exchange.TO_ENDPOINT));
+                        })
+                        .to("mock:result");
+
+                from("direct:b").pollEnrich("seda:bar")
+                        .process(e -> {
+                            Assertions.assertEquals("seda://bar", e.getProperty(Exchange.TO_ENDPOINT));
+                        })
+                        .to("mock:result");
             }
         };
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java
index d2d31cf5571..c7b1e60519e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java
@@ -49,7 +49,6 @@ public class PollEnricherTest extends ContextTestSupport {
         template.sendBody("seda:foo1", "blah");
 
         mock.expectedBodiesReceived("test:blah");
-        mock.expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://foo1");
 
         template.sendBody("direct:enricher-test-1", "test");
 
@@ -60,7 +59,7 @@ public class PollEnricherTest extends ContextTestSupport {
     public void testPollEnrichInOnlyWaitWithTimeout() throws InterruptedException {
         // this first try there is no data so we timeout
         mock.expectedBodiesReceived("test:blah");
-        mock.expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://foo2");
+
         template.sendBody("direct:enricher-test-2", "test");
         // not expected data so we are not happy
         mock.assertIsNotSatisfied();
@@ -88,7 +87,7 @@ public class PollEnricherTest extends ContextTestSupport {
 
         long start = System.currentTimeMillis();
         mock.expectedBodiesReceived("test:blah");
-        mock.expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://foo3");
+
         t.start();
         template.sendBody("direct:enricher-test-3", "test");
         // should take approx 1 sec to complete as the other thread is sending a
@@ -122,7 +121,6 @@ public class PollEnricherTest extends ContextTestSupport {
         });
         assertEquals("bar", exchange.getIn().getHeader("foo"));
         assertEquals("test:blah", exchange.getIn().getBody());
-        assertEquals("seda://foo4", exchange.getMessage().getHeader(Exchange.TO_ENDPOINT));
         assertNull(exchange.getException());
     }
 
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/HealthCheckComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/HealthCheckComponent.java
index 99cfd4f40f8..de0107f75a2 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/HealthCheckComponent.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/HealthCheckComponent.java
@@ -57,9 +57,9 @@ public abstract class HealthCheckComponent extends DefaultComponent {
     }
 
     /**
-     * Used for enabling or disabling all producer based health checks from this component.
-     * Notice: Camel has by default disabled all producer based health-checks.
-     * You can turn on producer checks globally by setting camel.health.producersEnabled=true.
+     * Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default
+     * disabled all producer based health-checks. You can turn on producer checks globally by setting
+     * camel.health.producersEnabled=true.
      */
     public void setHealthCheckProducerEnabled(boolean healthCheckProducerEnabled) {
         this.healthCheckProducerEnabled = healthCheckProducerEnabled;
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
index f5843df91ab..70a97dcae96 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
@@ -98,6 +98,50 @@ Removed `lang` attribute for the `<description>` on every EIPs.
 The `InOnly` and `InOut` EIPs has been removed.
 Instead, use `SetExchangePattern` or `To` where you can specify exchange pattern to use.
 
+=== Poll Enrich EIP
+
+The polled endpoint URI is now stored as property on the `Exchange` (with key `CamelToEndpoint`) like all other EIPs.
+Before the URI was stored as a message header.
+
+== CircuitBreaker EIP
+
+The following options in `camel-resilience4j` was mistakenly not defined as attributes:
+
+|===
+| *Option*
+| bulkheadEnabled
+| bulkheadMaxConcurrentCalls
+| bulkheadMaxWaitDuration
+| timeoutEnabled
+| timeoutExecutorService
+| timeoutDuration
+| timeoutCancelRunningFuture
+|===
+
+These options were not exposed in YAML DSL, and in XML DSL you need to migrate from:
+
+[source,xml]
+----
+<circuitBreaker>
+    <resilience4jConfiguration>
+        <timeoutEnabled>true</timeoutEnabled>
+        <timeoutDuration>2000</timeoutDuration>
+    </resilience4jConfiguration>
+...
+</circuitBreaker>
+----
+
+To use attributes instead:
+
+[source,xml]
+----
+<circuitBreaker>
+    <resilience4jConfiguration timeoutEnabled="true" timeoutDuration="2000"/>
+...
+</circuitBreaker>
+----
+
+
 == XML DSL
 
 The `<description>` to set a description on a route or node, has been changed from an element to an attribute.
@@ -224,44 +268,6 @@ that contains the input and outgoing (if `InOut`) messages.
 The default xml serialization using `ModelToXMLDumper` has been improved and now uses a generated xml
 serializer located in the `camel-xml-io` module instead of the JAXB based one from `camel-jaxb`.
 
-== CircuitBreaker EIP
-
-The following options in `camel-resilience4j` was mistakenly not defined as attributes:
-
-|===
-| *Option*
-| bulkheadEnabled
-| bulkheadMaxConcurrentCalls
-| bulkheadMaxWaitDuration
-| timeoutEnabled
-| timeoutExecutorService
-| timeoutDuration
-| timeoutCancelRunningFuture
-|===
-
-These options were not exposed in YAML DSL, and in XML DSL you need to migrate from:
-
-[source,xml]
-----
-<circuitBreaker>
-    <resilience4jConfiguration>
-        <timeoutEnabled>true</timeoutEnabled>
-        <timeoutDuration>2000</timeoutDuration>
-    </resilience4jConfiguration>
-...
-</circuitBreaker>
-----
-
-To use attributes instead:
-
-[source,xml]
-----
-<circuitBreaker>
-    <resilience4jConfiguration timeoutEnabled="true" timeoutDuration="2000"/>
-...
-</circuitBreaker>
-----
-
 == OpenAPI Maven Plugin
 
 The `camel-restdsl-openapi-plugin` Maven plugin now uses `platform-http` as the default rest component