Skip to content

Commit ec48a00

Browse files
authored
CAMEL-15088: camel-dapr - add Dapr component, invokeService operation (#17818)
* CAMEL-15088: camel-dapr - add Dapr component, invokeService operation * CAMEL-15088: camel-dapr - fix dependency issue, update docs with invokeService description and examples
1 parent 09f8f95 commit ec48a00

File tree

51 files changed

+2230
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2230
-0
lines changed

bom/camel-bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,11 @@
602602
<artifactId>camel-cxf-transport</artifactId>
603603
<version>4.12.0-SNAPSHOT</version>
604604
</dependency>
605+
<dependency>
606+
<groupId>org.apache.camel</groupId>
607+
<artifactId>camel-dapr</artifactId>
608+
<version>4.12.0-SNAPSHOT</version>
609+
</dependency>
605610
<dependency>
606611
<groupId>org.apache.camel</groupId>
607612
<artifactId>camel-dataformat</artifactId>

catalog/camel-allcomponents/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@
496496
<artifactId>camel-cxf-transport</artifactId>
497497
<version>${project.version}</version>
498498
</dependency>
499+
<dependency>
500+
<groupId>org.apache.camel</groupId>
501+
<artifactId>camel-dapr</artifactId>
502+
<version>${project.version}</version>
503+
</dependency>
499504
<dependency>
500505
<groupId>org.apache.camel</groupId>
501506
<artifactId>camel-dataformat</artifactId>

catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ cron
7373
crypto
7474
cxf
7575
cxfrs
76+
dapr
7677
dataformat
7778
dataset
7879
dataset-test
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"component": {
3+
"kind": "component",
4+
"name": "dapr",
5+
"title": "Dapr",
6+
"description": "Dapr component which interfaces with Dapr Building Blocks.",
7+
"deprecated": false,
8+
"firstVersion": "4.12.0",
9+
"label": "cloud,saas",
10+
"javaType": "org.apache.camel.component.dapr.DaprComponent",
11+
"supportLevel": "Preview",
12+
"groupId": "org.apache.camel",
13+
"artifactId": "camel-dapr",
14+
"version": "4.12.0-SNAPSHOT",
15+
"scheme": "dapr",
16+
"extendsScheme": "",
17+
"syntax": "dapr:operation",
18+
"async": false,
19+
"api": false,
20+
"consumerOnly": false,
21+
"producerOnly": true,
22+
"lenientProperties": false,
23+
"browsable": false,
24+
"remote": true
25+
},
26+
"componentProperties": {
27+
"configuration": { "index": 0, "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.dapr.DaprConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The component configurations" },
28+
"httpExtension": { "index": 1, "kind": "property", "displayName": "Http Extension", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "io.dapr.client.domain.HttpExtension", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "HTTP method to use when invoking the service. Accepts verbs like GET, POST, PUT, DELETE, etc. Creates a minimal HttpExtension with no headers or query params. Takes precedence over verb" },
29+
"lazyStartProducer": { "index": 2, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." },
30+
"methodToInvoke": { "index": 3, "kind": "property", "displayName": "Method To Invoke", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "The name of the method or route to invoke on the target service" },
31+
"serviceToInvoke": { "index": 4, "kind": "property", "displayName": "Service To Invoke", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "Target service to invoke. Can be a Dapr App ID, a named HTTPEndpoint, or a FQDN\/public URL" },
32+
"verb": { "index": 5, "kind": "property", "displayName": "Verb", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "POST", "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "The HTTP verb to use for invoking the method" },
33+
"autowiredEnabled": { "index": 6, "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 type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }
34+
},
35+
"headers": {
36+
"CamelDaprServiceToInvoke": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Target service to invoke. Can be a Dapr App ID, a named HTTPEndpoint, or a FQDN\/public URL", "constantName": "org.apache.camel.component.dapr.DaprConstants#SERVICE_TO_INVOKE" },
37+
"CamelDaprMethodToInvoke": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the method or route to invoke on the target service", "constantName": "org.apache.camel.component.dapr.DaprConstants#METHOD_TO_INVOKE" },
38+
"CamelDaprVerb": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The HTTP verb to use for service invocation", "constantName": "org.apache.camel.component.dapr.DaprConstants#VERB" },
39+
"CamelDaprQueryParameters": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Map<String, List<String>>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The query parameters for HTTP requests", "constantName": "org.apache.camel.component.dapr.DaprConstants#QUERY_PARAMETERS" },
40+
"CamelDaprHttpHeaders": { "index": 4, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Map<String, String>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The headers for HTTP requests", "constantName": "org.apache.camel.component.dapr.DaprConstants#HTTP_HEADERS" },
41+
"CamelDaprHttpExtension": { "index": 5, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "HttpExtension", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The HttpExtension object for service invocation. Takes precedence over verb", "constantName": "org.apache.camel.component.dapr.DaprConstants#HTTP_EXTENSION" }
42+
},
43+
"properties": {
44+
"operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "producer", "required": true, "type": "object", "javaType": "org.apache.camel.component.dapr.DaprOperation", "enum": [ "invokeService" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "The Dapr building block operation to perform with this component" },
45+
"httpExtension": { "index": 1, "kind": "parameter", "displayName": "Http Extension", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "io.dapr.client.domain.HttpExtension", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "HTTP method to use when invoking the service. Accepts verbs like GET, POST, PUT, DELETE, etc. Creates a minimal HttpExtension with no headers or query params. Takes precedence over verb" },
46+
"methodToInvoke": { "index": 2, "kind": "parameter", "displayName": "Method To Invoke", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "The name of the method or route to invoke on the target service" },
47+
"serviceToInvoke": { "index": 3, "kind": "parameter", "displayName": "Service To Invoke", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "Target service to invoke. Can be a Dapr App ID, a named HTTPEndpoint, or a FQDN\/public URL" },
48+
"verb": { "index": 4, "kind": "parameter", "displayName": "Verb", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "POST", "configurationClass": "org.apache.camel.component.dapr.DaprConfiguration", "configurationField": "configuration", "description": "The HTTP verb to use for invoking the method" },
49+
"lazyStartProducer": { "index": 5, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }
50+
}
51+
}

catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cluster
88
componentdsl
99
console
1010
csimple-joor
11+
dapr
1112
debug
1213
dsl-modeline
1314
elytron
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"other": {
3+
"kind": "other",
4+
"name": "dapr",
5+
"title": "Dapr",
6+
"description": "Camel Dapr component",
7+
"deprecated": false,
8+
"firstVersion": "4.11.0",
9+
"supportLevel": "Preview",
10+
"groupId": "org.apache.camel",
11+
"artifactId": "camel-dapr",
12+
"version": "4.12.0-SNAPSHOT"
13+
}
14+
}

components/camel-dapr/pom.xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
22+
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<parent>
26+
<artifactId>components</artifactId>
27+
<groupId>org.apache.camel</groupId>
28+
<version>4.12.0-SNAPSHOT</version>
29+
</parent>
30+
31+
<artifactId>camel-dapr</artifactId>
32+
<packaging>jar</packaging>
33+
<name>Camel :: Dapr</name>
34+
<description>Camel Dapr component</description>
35+
36+
<properties>
37+
<firstVersion>4.12.0</firstVersion>
38+
</properties>
39+
40+
<dependencies>
41+
42+
<!-- camel -->
43+
<dependency>
44+
<groupId>org.apache.camel</groupId>
45+
<artifactId>camel-support</artifactId>
46+
</dependency>
47+
48+
<!-- dapr -->
49+
<dependency>
50+
<groupId>io.dapr</groupId>
51+
<artifactId>dapr-sdk</artifactId>
52+
<version>${dapr-version}</version>
53+
</dependency>
54+
55+
<!-- logging -->
56+
<dependency>
57+
<groupId>org.apache.logging.log4j</groupId>
58+
<artifactId>log4j-slf4j2-impl</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.apache.logging.log4j</groupId>
63+
<artifactId>log4j-core</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
67+
<!-- for testing -->
68+
<dependency>
69+
<groupId>org.apache.camel</groupId>
70+
<artifactId>camel-test-junit5</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.mockito</groupId>
75+
<artifactId>mockito-junit-jupiter</artifactId>
76+
<version>${mockito-version}</version>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.apache.commons</groupId>
81+
<artifactId>commons-lang3</artifactId>
82+
<scope>test</scope>
83+
</dependency>
84+
85+
</dependencies>
86+
87+
</project>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* Generated by camel build tools - do NOT edit this file! */
2+
package org.apache.camel.component.dapr;
3+
4+
import javax.annotation.processing.Generated;
5+
import java.util.Map;
6+
7+
import org.apache.camel.CamelContext;
8+
import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
9+
import org.apache.camel.spi.PropertyConfigurerGetter;
10+
import org.apache.camel.spi.ConfigurerStrategy;
11+
import org.apache.camel.spi.GeneratedPropertyConfigurer;
12+
import org.apache.camel.util.CaseInsensitiveMap;
13+
import org.apache.camel.support.component.PropertyConfigurerSupport;
14+
15+
/**
16+
* Generated by camel build tools - do NOT edit this file!
17+
*/
18+
@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo")
19+
@SuppressWarnings("unchecked")
20+
public class DaprComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
21+
22+
private org.apache.camel.component.dapr.DaprConfiguration getOrCreateConfiguration(DaprComponent target) {
23+
if (target.getConfiguration() == null) {
24+
target.setConfiguration(new org.apache.camel.component.dapr.DaprConfiguration());
25+
}
26+
return target.getConfiguration();
27+
}
28+
29+
@Override
30+
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
31+
DaprComponent target = (DaprComponent) obj;
32+
switch (ignoreCase ? name.toLowerCase() : name) {
33+
case "autowiredenabled":
34+
case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
35+
case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.dapr.DaprConfiguration.class, value)); return true;
36+
case "httpextension":
37+
case "httpExtension": getOrCreateConfiguration(target).setHttpExtension(property(camelContext, io.dapr.client.domain.HttpExtension.class, value)); return true;
38+
case "lazystartproducer":
39+
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
40+
case "methodtoinvoke":
41+
case "methodToInvoke": getOrCreateConfiguration(target).setMethodToInvoke(property(camelContext, java.lang.String.class, value)); return true;
42+
case "servicetoinvoke":
43+
case "serviceToInvoke": getOrCreateConfiguration(target).setServiceToInvoke(property(camelContext, java.lang.String.class, value)); return true;
44+
case "verb": getOrCreateConfiguration(target).setVerb(property(camelContext, java.lang.String.class, value)); return true;
45+
default: return false;
46+
}
47+
}
48+
49+
@Override
50+
public String[] getAutowiredNames() {
51+
return new String[]{"httpExtension"};
52+
}
53+
54+
@Override
55+
public Class<?> getOptionType(String name, boolean ignoreCase) {
56+
switch (ignoreCase ? name.toLowerCase() : name) {
57+
case "autowiredenabled":
58+
case "autowiredEnabled": return boolean.class;
59+
case "configuration": return org.apache.camel.component.dapr.DaprConfiguration.class;
60+
case "httpextension":
61+
case "httpExtension": return io.dapr.client.domain.HttpExtension.class;
62+
case "lazystartproducer":
63+
case "lazyStartProducer": return boolean.class;
64+
case "methodtoinvoke":
65+
case "methodToInvoke": return java.lang.String.class;
66+
case "servicetoinvoke":
67+
case "serviceToInvoke": return java.lang.String.class;
68+
case "verb": return java.lang.String.class;
69+
default: return null;
70+
}
71+
}
72+
73+
@Override
74+
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
75+
DaprComponent target = (DaprComponent) obj;
76+
switch (ignoreCase ? name.toLowerCase() : name) {
77+
case "autowiredenabled":
78+
case "autowiredEnabled": return target.isAutowiredEnabled();
79+
case "configuration": return target.getConfiguration();
80+
case "httpextension":
81+
case "httpExtension": return getOrCreateConfiguration(target).getHttpExtension();
82+
case "lazystartproducer":
83+
case "lazyStartProducer": return target.isLazyStartProducer();
84+
case "methodtoinvoke":
85+
case "methodToInvoke": return getOrCreateConfiguration(target).getMethodToInvoke();
86+
case "servicetoinvoke":
87+
case "serviceToInvoke": return getOrCreateConfiguration(target).getServiceToInvoke();
88+
case "verb": return getOrCreateConfiguration(target).getVerb();
89+
default: return null;
90+
}
91+
}
92+
}
93+

0 commit comments

Comments
 (0)