Skip to content

CAMEL-15088: camel-dapr - add Dapr component, invokeService operation #17818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bom/camel-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,11 @@
<artifactId>camel-cxf-transport</artifactId>
<version>4.12.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-dapr</artifactId>
<version>4.12.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-dataformat</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions catalog/camel-allcomponents/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@
<artifactId>camel-cxf-transport</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-dapr</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-dataformat</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ cron
crypto
cxf
cxfrs
dapr
dataformat
dataset
dataset-test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"component": {
"kind": "component",
"name": "dapr",
"title": "Dapr",
"description": "Dapr component which interfaces with Dapr Building Blocks.",
"deprecated": false,
"firstVersion": "4.12.0",
"label": "cloud,saas",
"javaType": "org.apache.camel.component.dapr.DaprComponent",
"supportLevel": "Preview",
"groupId": "org.apache.camel",
"artifactId": "camel-dapr",
"version": "4.12.0-SNAPSHOT",
"scheme": "dapr",
"extendsScheme": "",
"syntax": "dapr:operation",
"async": false,
"api": false,
"consumerOnly": false,
"producerOnly": true,
"lenientProperties": false,
"browsable": false,
"remote": true
},
"componentProperties": {
"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" },
"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" },
"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." },
"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" },
"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" },
"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" },
"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." }
},
"headers": {
"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" },
"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" },
"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" },
"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" },
"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" },
"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" }
},
"properties": {
"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" },
"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" },
"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" },
"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" },
"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" },
"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." }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cluster
componentdsl
console
csimple-joor
dapr
debug
dsl-modeline
elytron
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"other": {
"kind": "other",
"name": "dapr",
"title": "Dapr",
"description": "Camel Dapr component",
"deprecated": false,
"firstVersion": "4.11.0",
"supportLevel": "Preview",
"groupId": "org.apache.camel",
"artifactId": "camel-dapr",
"version": "4.12.0-SNAPSHOT"
}
}
87 changes: 87 additions & 0 deletions components/camel-dapr/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>components</artifactId>
<groupId>org.apache.camel</groupId>
<version>4.12.0-SNAPSHOT</version>
</parent>

<artifactId>camel-dapr</artifactId>
<packaging>jar</packaging>
<name>Camel :: Dapr</name>
<description>Camel Dapr component</description>

<properties>
<firstVersion>4.12.0</firstVersion>
</properties>

<dependencies>

<!-- camel -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-support</artifactId>
</dependency>

<!-- dapr -->
<dependency>
<groupId>io.dapr</groupId>
<artifactId>dapr-sdk</artifactId>
<version>${dapr-version}</version>
</dependency>

<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>

<!-- for testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/* Generated by camel build tools - do NOT edit this file! */
package org.apache.camel.component.dapr;

import javax.annotation.processing.Generated;
import java.util.Map;

import org.apache.camel.CamelContext;
import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.spi.ConfigurerStrategy;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.util.CaseInsensitiveMap;
import org.apache.camel.support.component.PropertyConfigurerSupport;

/**
* Generated by camel build tools - do NOT edit this file!
*/
@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo")
@SuppressWarnings("unchecked")
public class DaprComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {

private org.apache.camel.component.dapr.DaprConfiguration getOrCreateConfiguration(DaprComponent target) {
if (target.getConfiguration() == null) {
target.setConfiguration(new org.apache.camel.component.dapr.DaprConfiguration());
}
return target.getConfiguration();
}

@Override
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
DaprComponent target = (DaprComponent) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.dapr.DaprConfiguration.class, value)); return true;
case "httpextension":
case "httpExtension": getOrCreateConfiguration(target).setHttpExtension(property(camelContext, io.dapr.client.domain.HttpExtension.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
case "methodtoinvoke":
case "methodToInvoke": getOrCreateConfiguration(target).setMethodToInvoke(property(camelContext, java.lang.String.class, value)); return true;
case "servicetoinvoke":
case "serviceToInvoke": getOrCreateConfiguration(target).setServiceToInvoke(property(camelContext, java.lang.String.class, value)); return true;
case "verb": getOrCreateConfiguration(target).setVerb(property(camelContext, java.lang.String.class, value)); return true;
default: return false;
}
}

@Override
public String[] getAutowiredNames() {
return new String[]{"httpExtension"};
}

@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled": return boolean.class;
case "configuration": return org.apache.camel.component.dapr.DaprConfiguration.class;
case "httpextension":
case "httpExtension": return io.dapr.client.domain.HttpExtension.class;
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
case "methodtoinvoke":
case "methodToInvoke": return java.lang.String.class;
case "servicetoinvoke":
case "serviceToInvoke": return java.lang.String.class;
case "verb": return java.lang.String.class;
default: return null;
}
}

@Override
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
DaprComponent target = (DaprComponent) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled": return target.isAutowiredEnabled();
case "configuration": return target.getConfiguration();
case "httpextension":
case "httpExtension": return getOrCreateConfiguration(target).getHttpExtension();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
case "methodtoinvoke":
case "methodToInvoke": return getOrCreateConfiguration(target).getMethodToInvoke();
case "servicetoinvoke":
case "serviceToInvoke": return getOrCreateConfiguration(target).getServiceToInvoke();
case "verb": return getOrCreateConfiguration(target).getVerb();
default: return null;
}
}
}

Loading