This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch tap in repository https://gitbox.apache.org/repos/asf/camel.git
commit 81a304604a17f2c9b85cc7ad06de413225fd1afc Author: Claus Ibsen <[email protected]> AuthorDate: Mon Feb 16 17:31:06 2026 +0100 CAMEL-23017: camel-core - WireTap EIP should not have pattern option --- .../org/apache/camel/catalog/models/wireTap.json | 9 ++- .../main/docs/modules/eips/pages/sample-eip.adoc | 69 +++++++++++++++++++++- .../META-INF/org/apache/camel/model/wireTap.json | 9 ++- .../apache/camel/model/ProcessorDefinition.java | 4 +- .../org/apache/camel/model/WireTapDefinition.java | 5 +- .../apache/camel/processor/WireTapProcessor.java | 8 +-- .../org/apache/camel/reifier/WireTapReifier.java | 8 +-- .../camel/processor/SamplingThrottlerTest.java | 3 +- .../apache/camel/processor/WireTapPatternTest.java | 55 +++++++++++++++++ .../ROOT/pages/camel-4x-upgrade-guide-4_19.adoc | 19 ++++++ .../modules/ROOT/pages/camel-4x-upgrade-guide.adoc | 1 + .../src/main/resources/templates/code-java.tmpl | 1 + .../dsl/yaml/deserializers/ModelDeserializers.java | 6 -- .../dsl/yaml/GenerateYamlDeserializersMojo.java | 4 ++ .../maven/dsl/yaml/GenerateYamlSchemaMojo.java | 13 ++++ .../generated/resources/schema/camelYamlDsl.json | 6 -- .../camel/maven/packaging/SchemaGeneratorMojo.java | 14 ++++- 17 files changed, 192 insertions(+), 42 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/wireTap.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/wireTap.json index 882f6e29b69d..90d59b572270 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/wireTap.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/wireTap.json @@ -23,11 +23,10 @@ "uri": { "index": 8, "kind": "attribute", "displayName": "Uri", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The uri of the endpoint to send to. The uri can be dynamic computed using the org.apache.camel.language.simple.SimpleLanguage expression." }, "variableSend": { "index": 9, "kind": "attribute", "displayName": "Variable Send", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is tak [...] "variableReceive": { "index": 10, "kind": "attribute", "displayName": "Variable Receive", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body [...] - "pattern": { "index": 11, "kind": "attribute", "displayName": "Pattern", "group": "advanced", "label": "advanced", "required": false, "type": "enum", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the optional ExchangePattern used to invoke this endpoint" }, - "cacheSize": { "index": 12, "kind": "attribute", "displayName": "Cache Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this recipient list, when uris are reused. Beware that when using dynamic endpoints then it affects [...] - "ignoreInvalidEndpoint": { "index": 13, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore invalid endpoint URIs and skip sending the message." }, - "allowOptimisedComponents": { "index": 14, "kind": "attribute", "displayName": "Allow Optimised Components", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow components to optimise toD if they are org.apache.camel.spi.SendDynamicAware ." }, - "autoStartComponents": { "index": 15, "kind": "attribute", "displayName": "Auto Start Components", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to auto startup components when toD is starting up." } + "cacheSize": { "index": 11, "kind": "attribute", "displayName": "Cache Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this recipient list, when uris are reused. Beware that when using dynamic endpoints then it affects [...] + "ignoreInvalidEndpoint": { "index": 12, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore invalid endpoint URIs and skip sending the message." }, + "allowOptimisedComponents": { "index": 13, "kind": "attribute", "displayName": "Allow Optimised Components", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow components to optimise toD if they are org.apache.camel.spi.SendDynamicAware ." }, + "autoStartComponents": { "index": 14, "kind": "attribute", "displayName": "Auto Start Components", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to auto startup components when toD is starting up." } }, "exchangeProperties": { "CamelToEndpoint": { "index": 0, "kind": "exchangeProperty", "displayName": "To Endpoint", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "autowired": false, "secret": false, "description": "Endpoint URI where this Exchange is being sent to" } diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/sample-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/sample-eip.adoc index cbe0fb955301..329b834983dc 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/sample-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/sample-eip.adoc @@ -50,6 +50,19 @@ XML:: <to uri="direct:sampled"/> </route> ---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:sample + steps: + - sample: {} + - to: + uri: direct:sampled +---- ==== === Sampling using time period @@ -64,7 +77,7 @@ Java:: [source,java] ---- from("direct:sample") - .sample(Duration.of(5, ChronoUnit.SECONDS)) + .sample(Duration.ofSeconds(5)) .to("direct:sampled"); ---- @@ -74,10 +87,24 @@ XML:: ---- <route> <from uri="direct:sample"/> - <sample samplePeriod="5000"/> + <sample samplePeriod="5s"/> <to uri="direct:sampled"/> </route> ---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:sample + steps: + - sample: + samplePeriod: 5s + - to: + uri: direct:sampled +---- ==== === Sampling using message frequency @@ -107,6 +134,20 @@ XML:: <to uri="direct:sampled"/> </route> ---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:sample + steps: + - sample: + messageFrequency: 10 + - to: + uri: direct:sampled +---- ==== === Sampling with wiretap @@ -125,7 +166,7 @@ Java:: ---- from("direct:start") .wireTap("direct:sample") - .to("direct:regularProcessing") + .to("direct:regularProcessing"); from("direct:sample") .sample(10) @@ -148,4 +189,26 @@ XML:: <to uri="direct:sampleProcessing"/> </route> ---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:start + steps: + - wireTap: + uri: direct:sample + - to: + uri: direct:regularProcessing +- route: + from: + uri: direct:sample + steps: + - sample: + messageFrequency: 10 + - to: + uri: direct:sampleProcessing +---- ==== diff --git a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/wireTap.json b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/wireTap.json index 882f6e29b69d..90d59b572270 100644 --- a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/wireTap.json +++ b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/wireTap.json @@ -23,11 +23,10 @@ "uri": { "index": 8, "kind": "attribute", "displayName": "Uri", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The uri of the endpoint to send to. The uri can be dynamic computed using the org.apache.camel.language.simple.SimpleLanguage expression." }, "variableSend": { "index": 9, "kind": "attribute", "displayName": "Variable Send", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is tak [...] "variableReceive": { "index": 10, "kind": "attribute", "displayName": "Variable Receive", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body [...] - "pattern": { "index": 11, "kind": "attribute", "displayName": "Pattern", "group": "advanced", "label": "advanced", "required": false, "type": "enum", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the optional ExchangePattern used to invoke this endpoint" }, - "cacheSize": { "index": 12, "kind": "attribute", "displayName": "Cache Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this recipient list, when uris are reused. Beware that when using dynamic endpoints then it affects [...] - "ignoreInvalidEndpoint": { "index": 13, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore invalid endpoint URIs and skip sending the message." }, - "allowOptimisedComponents": { "index": 14, "kind": "attribute", "displayName": "Allow Optimised Components", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow components to optimise toD if they are org.apache.camel.spi.SendDynamicAware ." }, - "autoStartComponents": { "index": 15, "kind": "attribute", "displayName": "Auto Start Components", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to auto startup components when toD is starting up." } + "cacheSize": { "index": 11, "kind": "attribute", "displayName": "Cache Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this recipient list, when uris are reused. Beware that when using dynamic endpoints then it affects [...] + "ignoreInvalidEndpoint": { "index": 12, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to ignore invalid endpoint URIs and skip sending the message." }, + "allowOptimisedComponents": { "index": 13, "kind": "attribute", "displayName": "Allow Optimised Components", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow components to optimise toD if they are org.apache.camel.spi.SendDynamicAware ." }, + "autoStartComponents": { "index": 14, "kind": "attribute", "displayName": "Auto Start Components", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to auto startup components when toD is starting up." } }, "exchangeProperties": { "CamelToEndpoint": { "index": 0, "kind": "exchangeProperty", "displayName": "To Endpoint", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "autowired": false, "secret": false, "description": "Endpoint URI where this Exchange is being sent to" } 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 8cd6f8271c31..64a51fe942a5 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 @@ -1829,7 +1829,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ public SamplingDefinition sample() { - return sample(Duration.ofSeconds(1)); + SamplingDefinition answer = new SamplingDefinition(); + addOutput(answer); + return answer; } /** diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/WireTapDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/WireTapDefinition.java index f214b23fdf05..7a155184c508 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/WireTapDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/WireTapDefinition.java @@ -24,7 +24,6 @@ import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlTransient; -import org.apache.camel.ExchangePattern; import org.apache.camel.Message; import org.apache.camel.Processor; import org.apache.camel.spi.Metadata; @@ -33,7 +32,7 @@ import org.apache.camel.spi.Metadata; * Routes a copy of a message (or creates a new message) to a secondary destination while continue routing the original * message. */ -@Metadata(label = "eip,routing") +@Metadata(label = "eip,routing", excludeProperties = "pattern") @XmlRootElement(name = "wireTap") @XmlAccessorType(XmlAccessType.FIELD) public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends ToDynamicDefinition @@ -72,7 +71,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T @Override public String getPattern() { - return ExchangePattern.InOnly.name(); + return null; // not in use } @Override diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/WireTapProcessor.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/WireTapProcessor.java index a1a911228274..59a18a5976ae 100644 --- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/WireTapProcessor.java +++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/WireTapProcessor.java @@ -60,7 +60,6 @@ public class WireTapProcessor extends BaseProcessorSupport private final boolean dynamicUri; private final Processor processor; private final AsyncProcessor asyncProcessor; - private final ExchangePattern exchangePattern; private final boolean copy; private final ExecutorService executorService; private final boolean shutdownExecutorService; @@ -70,13 +69,12 @@ public class WireTapProcessor extends BaseProcessorSupport private Processor onPrepare; public WireTapProcessor(SendDynamicProcessor dynamicSendProcessor, Processor processor, String uri, - ExchangePattern exchangePattern, boolean copy, + boolean copy, ExecutorService executorService, boolean shutdownExecutorService, boolean dynamicUri) { this.dynamicSendProcessor = dynamicSendProcessor; this.uri = uri; this.processor = processor; this.asyncProcessor = AsyncProcessorConverterHelper.convert(processor); - this.exchangePattern = exchangePattern; this.copy = copy; ObjectHelper.notNull(executorService, "executorService"); this.executorService = executorService; @@ -190,7 +188,7 @@ public class WireTapProcessor extends BaseProcessorSupport // must configure the wire tap beforehand Exchange target; try { - target = configureExchange(exchange, exchangePattern); + target = configureExchange(exchange); } catch (Exception e) { exchange.setException(e); callback.done(true); @@ -214,7 +212,7 @@ public class WireTapProcessor extends BaseProcessorSupport return true; } - protected Exchange configureExchange(Exchange exchange, ExchangePattern pattern) throws IOException { + protected Exchange configureExchange(Exchange exchange) throws IOException { Exchange answer; if (copy) { // use a copy of the original exchange diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/WireTapReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/WireTapReifier.java index 5e4e2abf2d4a..57cd5604e1ff 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/WireTapReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/WireTapReifier.java @@ -50,9 +50,6 @@ public class WireTapReifier extends ToDynamicReifier<WireTapDefinition<?>> { throw new IllegalArgumentException("WireTap does not support variableReceive"); } - // must use InOnly for WireTap - definition.setPattern(ExchangePattern.InOnly.name()); - // executor service is mandatory for wire tap boolean shutdownThreadPool = willCreateNewThreadPool(definition, true); ExecutorService threadPool = getConfiguredExecutorService("WireTap", definition, true); @@ -79,6 +76,8 @@ public class WireTapReifier extends ToDynamicReifier<WireTapDefinition<?>> { if (dynamic && simple || invalid) { // dynamic or ignore-invalid so we need the dynamic send processor dynamicSendProcessor = (SendDynamicProcessor) super.createProcessor(); + // must use InOnly pattern + dynamicSendProcessor.setPattern(ExchangePattern.InOnly); } else { // static so we can use a plain send processor Endpoint endpoint = CamelContextHelper.resolveEndpoint(camelContext, uri, null); @@ -100,8 +99,7 @@ public class WireTapReifier extends ToDynamicReifier<WireTapDefinition<?>> { boolean isCopy = parseBoolean(definition.getCopy(), true); WireTapProcessor answer = new WireTapProcessor( - dynamicSendProcessor, target, uri, - parse(ExchangePattern.class, definition.getPattern()), isCopy, + dynamicSendProcessor, target, uri, isCopy, threadPool, shutdownThreadPool, dynamic); answer.setDisabled(isDisabled(camelContext, definition)); Processor prepare = definition.getOnPrepareProcessor(); diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java index f22eefe392a0..dc5a5193c735 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java @@ -17,7 +17,6 @@ package org.apache.camel.processor; import java.time.Duration; -import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -166,7 +165,7 @@ public class SamplingThrottlerTest extends ContextTestSupport { from("direct:sample-configured").sample("1000").to("mock:result"); - from("direct:sample-configured-via-dsl").sample(Duration.of(1, ChronoUnit.SECONDS)).to("mock:result"); + from("direct:sample-configured-via-dsl").sample(Duration.ofSeconds(1)).to("mock:result"); from("direct:sample-messageFrequency").sample(10).to("mock:result"); diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/WireTapPatternTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/WireTapPatternTest.java new file mode 100644 index 000000000000..ccf0ed5282ca --- /dev/null +++ b/core/camel-core/src/test/java/org/apache/camel/processor/WireTapPatternTest.java @@ -0,0 +1,55 @@ +/* + * 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 org.apache.camel.ContextTestSupport; +import org.apache.camel.ExchangePattern; +import org.apache.camel.builder.RouteBuilder; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class WireTapPatternTest extends ContextTestSupport { + + @Test + public void testWireTapPattern() throws Exception { + getMockEndpoint("mock:result").expectedMessageCount(1); + getMockEndpoint("mock:tap").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + + Assertions.assertEquals(ExchangePattern.InOut, + getMockEndpoint("mock:result").getReceivedExchanges().get(0).getPattern()); + Assertions.assertEquals(ExchangePattern.InOnly, getMockEndpoint("mock:tap").getReceivedExchanges().get(0).getPattern()); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start") + .setExchangePattern(ExchangePattern.InOut) + .wireTap("direct:tap") + .to("mock:result"); + + from("direct:tap") + .to("mock:tap"); + } + }; + } +} diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc new file mode 100644 index 000000000000..4f277bad8a04 --- /dev/null +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc @@ -0,0 +1,19 @@ += Apache Camel 4.x Upgrade Guide + +This document is for helping you upgrade your Apache Camel application +from Camel 4.x to 4.y. For example, if you are upgrading Camel 4.0 to 4.2, then you should follow the guides +from both 4.0 to 4.1 and 4.1 to 4.2. + +[NOTE] +==== +https://github.com/apache/camel-upgrade-recipes/[The Camel Upgrade Recipes project] provides automated assistance for some common migration tasks. +Note that manual migration is still required. +See the xref:camel-upgrade-recipes-tool.adoc[documentation] page for details. +==== + +== Upgrading Camel 4.18 to 4.19 + +=== camel-core + +The WireTap EIP has removed the `pattern` option from its model (not in use) as wiretap always +uses `InOnly` pattern. diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc index f30900ded3a6..2367b6b0acd7 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc @@ -27,6 +27,7 @@ You can find the upgrade guide for each release in the following pages: - xref:camel-4x-upgrade-guide-4_16.adoc[Upgrade guide 4.15 -> 4.16] - xref:camel-4x-upgrade-guide-4_17.adoc[Upgrade guide 4.16 -> 4.17] - xref:camel-4x-upgrade-guide-4_18.adoc[Upgrade guide 4.17 -> 4.18] +- xref:camel-4x-upgrade-guide-4_19.adoc[Upgrade guide 4.18 -> 4.19] [NOTE] ==== diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/code-java.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/code-java.tmpl index a2427fdcf288..cb8e1328fb28 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/code-java.tmpl +++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/code-java.tmpl @@ -1,3 +1,4 @@ +import java.time.*; import java.util.*; import java.util.concurrent.*; diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java index 36b706cf8aa7..98af5f3327b3 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java @@ -21595,7 +21595,6 @@ public final class ModelDeserializers extends YamlDeserializerSupport { @YamlProperty(name = "note", type = "string", description = "Sets the note of this node", displayName = "Note"), @YamlProperty(name = "onPrepare", type = "string", description = "Uses the Processor when preparing the org.apache.camel.Exchange to be sent. This can be used to deep-clone messages that should be sent, or any custom logic needed before the exchange is sent.", displayName = "On Prepare"), @YamlProperty(name = "parameters", type = "object"), - @YamlProperty(name = "pattern", type = "enum:InOnly,InOut", description = "Sets the optional ExchangePattern used to invoke this endpoint", displayName = "Pattern"), @YamlProperty(name = "uri", type = "string", required = true, description = "The uri of the endpoint to send to. The uri can be dynamic computed using the org.apache.camel.language.simple.SimpleLanguage expression.", displayName = "Uri"), @YamlProperty(name = "variableReceive", type = "string", description = "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is taken from this variable instead of the current Message , however the headers from the Message will still be used as well. In other words, the variable is used [...] @YamlProperty(name = "variableSend", type = "string", description = "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is taken from this variable instead of the current message, however the headers from the message will still be used as well. In other words, the variable is used inst [...] @@ -21667,11 +21666,6 @@ public final class ModelDeserializers extends YamlDeserializerSupport { target.setOnPrepare(val); break; } - case "pattern": { - String val = asText(node); - target.setPattern(val); - break; - } case "uri": { String val = asText(node); target.setUri(val); diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlDeserializersMojo.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlDeserializersMojo.java index c7a82dc08979..3468f481895f 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlDeserializersMojo.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlDeserializersMojo.java @@ -948,6 +948,10 @@ public class GenerateYamlDeserializersMojo extends GenerateYamlSupportMojo { // which should be skipped return true; } + // we want to skip pattern from wiretap + if ("pattern".equals(fieldName) && "wireTap".equals(modelName)) { + return true; + } // // Others diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlSchemaMojo.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlSchemaMojo.java index 46c3f031f91a..a1d6f9328926 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlSchemaMojo.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlSchemaMojo.java @@ -296,6 +296,19 @@ public class GenerateYamlSchemaMojo extends GenerateYamlSupportMojo { } } } + // we want to skip pattern from wiretap + if (propertyName.equals("pattern")) { + Optional<AnnotationValue> av = annotationValue(info, YAML_TYPE_ANNOTATION, "nodes"); + if (av.isPresent()) { + String[] sn = av.get().asStringArray(); + for (String n : sn) { + if ("wire-tap".equals(n) || "wireTap".equals(n)) { + skip = true; + break; + } + } + } + } if (skip) { continue; } diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json index 5a11dc7d76b7..229bac40f092 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json @@ -9274,12 +9274,6 @@ "parameters" : { "type" : "object" }, - "pattern" : { - "type" : "string", - "title" : "Pattern", - "description" : "Sets the optional ExchangePattern used to invoke this endpoint", - "enum" : [ "InOnly", "InOut" ] - }, "uri" : { "type" : "string", "title" : "Uri", diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java index a2b33e87fe3d..2a889de984ae 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java @@ -27,6 +27,7 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; @@ -266,12 +267,23 @@ public class SchemaGeneratorMojo extends AbstractGeneratorMojo { Set<EipOptionModel> eipOptions = new TreeSet<>(new EipOptionComparator(eipModel)); findClassProperties(eipOptions, classElement, classElement, "", name); - eipOptions.forEach(eipModel::addOption); + // the EIP may exclude some options + String excludedProperties = ""; + Metadata componentMetadata = classElement.getAnnotation(Metadata.class); + if (componentMetadata != null) { + excludedProperties = componentMetadata.excludeProperties(); + } + Set<String> excluded = new HashSet<>(); + Collections.addAll(excluded, excludedProperties.split(",")); + eipOptions.forEach(o -> { // compute group based on label for each option String group = EndpointHelper.labelAsGroupName(o.getLabel(), false, false); o.setGroup(group); }); + eipOptions.stream() + .filter(option -> !excluded.contains(option.getName())) + .forEach(eipModel::addOption); // after we have found all the options then figure out if the model // accepts input/output
