This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch phe in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/phe by this push: new 07c5ad3c1fe CAMEL-21300: camel-platform-http - Consumer should have option to control if writing response failing should cause Exchange to fail 07c5ad3c1fe is described below commit 07c5ad3c1fe00ab7f42ab86d33ee39ca371b177d Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Oct 2 10:33:49 2024 +0200 CAMEL-21300: camel-platform-http - Consumer should have option to control if writing response failing should cause Exchange to fail --- .../camel/catalog/components/platform-http.json | 7 ++++--- .../http/PlatformHttpComponentConfigurer.java | 6 ++++++ .../component/platform/http/platform-http.json | 7 ++++--- .../platform/http/PlatformHttpComponent.java | 17 ++++++++++++++--- .../dsl/PlatformHttpComponentBuilderFactory.java | 22 ++++++++++++++++++++++ 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json index ffca8a9a431..e38929d3a89 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json @@ -26,9 +26,10 @@ }, "componentProperties": { "bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the like [...] - "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] - "engine": { "index": 2, "kind": "property", "displayName": "Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests" }, - "headerFilterStrategy": { "index": 3, "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." } + "handleWriteResponseError": { "index": 1, "kind": "property", "displayName": "Handle Write Response Error", "group": "consumer", "label": "advanced,consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "When Camel is complete processing the message, and the HTTP server is writing response. This option controls whether Camel should catch any failure during writing response [...] + "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] + "engine": { "index": 3, "kind": "property", "displayName": "Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests" }, + "headerFilterStrategy": { "index": 4, "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." } }, "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The path under which this endpoint serves the HTTP requests, for proxy use 'proxy'" }, diff --git a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpComponentConfigurer.java b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpComponentConfigurer.java index 1ecee2a0874..6bac3f77b8e 100644 --- a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpComponentConfigurer.java +++ b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpComponentConfigurer.java @@ -28,6 +28,8 @@ public class PlatformHttpComponentConfigurer extends PropertyConfigurerSupport i case "bridgeerrorhandler": case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; case "engine": target.setEngine(property(camelContext, org.apache.camel.component.platform.http.spi.PlatformHttpEngine.class, value)); return true; + case "handlewriteresponseerror": + case "handleWriteResponseError": target.setHandleWriteResponseError(property(camelContext, boolean.class, value)); return true; case "headerfilterstrategy": case "headerFilterStrategy": target.setHeaderFilterStrategy(property(camelContext, org.apache.camel.spi.HeaderFilterStrategy.class, value)); return true; default: return false; @@ -42,6 +44,8 @@ public class PlatformHttpComponentConfigurer extends PropertyConfigurerSupport i case "bridgeerrorhandler": case "bridgeErrorHandler": return boolean.class; case "engine": return org.apache.camel.component.platform.http.spi.PlatformHttpEngine.class; + case "handlewriteresponseerror": + case "handleWriteResponseError": return boolean.class; case "headerfilterstrategy": case "headerFilterStrategy": return org.apache.camel.spi.HeaderFilterStrategy.class; default: return null; @@ -57,6 +61,8 @@ public class PlatformHttpComponentConfigurer extends PropertyConfigurerSupport i case "bridgeerrorhandler": case "bridgeErrorHandler": return target.isBridgeErrorHandler(); case "engine": return target.getEngine(); + case "handlewriteresponseerror": + case "handleWriteResponseError": return target.isHandleWriteResponseError(); case "headerfilterstrategy": case "headerFilterStrategy": return target.getHeaderFilterStrategy(); default: return null; diff --git a/components/camel-platform-http/src/generated/resources/META-INF/org/apache/camel/component/platform/http/platform-http.json b/components/camel-platform-http/src/generated/resources/META-INF/org/apache/camel/component/platform/http/platform-http.json index ffca8a9a431..e38929d3a89 100644 --- a/components/camel-platform-http/src/generated/resources/META-INF/org/apache/camel/component/platform/http/platform-http.json +++ b/components/camel-platform-http/src/generated/resources/META-INF/org/apache/camel/component/platform/http/platform-http.json @@ -26,9 +26,10 @@ }, "componentProperties": { "bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the like [...] - "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] - "engine": { "index": 2, "kind": "property", "displayName": "Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests" }, - "headerFilterStrategy": { "index": 3, "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." } + "handleWriteResponseError": { "index": 1, "kind": "property", "displayName": "Handle Write Response Error", "group": "consumer", "label": "advanced,consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "When Camel is complete processing the message, and the HTTP server is writing response. This option controls whether Camel should catch any failure during writing response [...] + "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] + "engine": { "index": 3, "kind": "property", "displayName": "Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests" }, + "headerFilterStrategy": { "index": 4, "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." } }, "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The path under which this endpoint serves the HTTP requests, for proxy use 'proxy'" }, diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java index 05fbb6f5d55..7872688d9a0 100644 --- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java @@ -56,13 +56,15 @@ public class PlatformHttpComponent extends HeaderFilterStrategyComponent @Metadata(label = "advanced", description = "An HTTP Server engine implementation to serve the requests") private volatile PlatformHttpEngine engine; + @Metadata(label = "advanced,consumer", defaultValue = "false", + description = "When Camel is complete processing the message, and the HTTP server is writing response. This option controls whether Camel" + + " should catch any failure during writing response and store this on the Exchange, which allows onCompletion/UnitOfWork to" + + " regard the Exchange as failed and have access to the caused exception from the HTTP server.") + private boolean handleWriteResponseError; private final Set<HttpEndpointModel> httpEndpoints = new TreeSet<>(); - private final List<PlatformHttpListener> listeners = new ArrayList<>(); - private volatile boolean localEngine; - private final Object lock = new Object(); public PlatformHttpComponent() { @@ -77,6 +79,7 @@ public class PlatformHttpComponent extends HeaderFilterStrategyComponent protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { PlatformHttpEndpoint endpoint = new PlatformHttpEndpoint(uri, remaining, this); endpoint.setPlatformHttpEngine(engine); + endpoint.setHandleWriteResponseError(handleWriteResponseError); setEndpointHeaderFilterStrategy(endpoint); setProperties(endpoint, parameters); return endpoint; @@ -194,6 +197,14 @@ public class PlatformHttpComponent extends HeaderFilterStrategyComponent this.engine = engine; } + public boolean isHandleWriteResponseError() { + return handleWriteResponseError; + } + + public void setHandleWriteResponseError(boolean handleWriteResponseError) { + this.handleWriteResponseError = handleWriteResponseError; + } + private Consumer doCreateConsumer( CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate, diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/PlatformHttpComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/PlatformHttpComponentBuilderFactory.java index 9d7f7130622..518054d750a 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/PlatformHttpComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/PlatformHttpComponentBuilderFactory.java @@ -81,6 +81,27 @@ public interface PlatformHttpComponentBuilderFactory { } + /** + * When Camel is complete processing the message, and the HTTP server is + * writing response. This option controls whether Camel should catch any + * failure during writing response and store this on the Exchange, which + * allows onCompletion/UnitOfWork to regard the Exchange as failed and + * have access to the caused exception from the HTTP server. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: consumer + * + * @param handleWriteResponseError the value to set + * @return the dsl builder + */ + default PlatformHttpComponentBuilder handleWriteResponseError(boolean handleWriteResponseError) { + doSetProperty("handleWriteResponseError", handleWriteResponseError); + return this; + } + + /** * Whether autowiring is enabled. This is used for automatic autowiring * options (the option must be marked as autowired) by looking up in the @@ -151,6 +172,7 @@ public interface PlatformHttpComponentBuilderFactory { Object value) { switch (name) { case "bridgeErrorHandler": ((PlatformHttpComponent) component).setBridgeErrorHandler((boolean) value); return true; + case "handleWriteResponseError": ((PlatformHttpComponent) component).setHandleWriteResponseError((boolean) value); return true; case "autowiredEnabled": ((PlatformHttpComponent) component).setAutowiredEnabled((boolean) value); return true; case "engine": ((PlatformHttpComponent) component).setEngine((org.apache.camel.component.platform.http.spi.PlatformHttpEngine) value); return true; case "headerFilterStrategy": ((PlatformHttpComponent) component).setHeaderFilterStrategy((org.apache.camel.spi.HeaderFilterStrategy) value); return true;