Skip to content

Commit

Permalink
CAMEL-20572 - Add Spring Boot Starter for Camel-Milvus (#1108)
Browse files Browse the repository at this point in the history
* CAMEL-20572 - Add Spring Boot Starter for Camel-Milvus

Signed-off-by: Andrea Cosentino <[email protected]>

* CAMEL-20572 - Add Spring Boot Starter for Camel-Milvus - Added test

Signed-off-by: Andrea Cosentino <[email protected]>

---------

Signed-off-by: Andrea Cosentino <[email protected]>
  • Loading branch information
oscerd authored Mar 15, 2024
1 parent 89555db commit 4eb78e0
Show file tree
Hide file tree
Showing 14 changed files with 753 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ mapstruct
master
metrics
micrometer
milvus
mina
minio
mllp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"component": {
"kind": "component",
"name": "milvus",
"title": "Milvus",
"description": "Perform operations on the Milvus Vector Database.",
"deprecated": false,
"firstVersion": "4.5.0",
"label": "database,ai",
"javaType": "org.apache.camel.component.milvus.MilvusComponent",
"supportLevel": "Preview",
"groupId": "org.apache.camel.springboot",
"artifactId": "camel-milvus-starter",
"version": "4.5.0-SNAPSHOT",
"scheme": "milvus",
"extendsScheme": "",
"syntax": "milvus:collection",
"async": false,
"api": false,
"consumerOnly": false,
"producerOnly": true,
"lenientProperties": false,
"remote": true
},
"componentProperties": {
"configuration": { "index": 0, "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.milvus.MilvusConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The configuration;" },
"host": { "index": 1, "kind": "property", "displayName": "Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "localhost", "configurationClass": "org.apache.camel.component.milvus.MilvusConfiguration", "configurationField": "configuration", "description": "The host to connect to." },
"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." },
"port": { "index": 3, "kind": "property", "displayName": "Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 19530, "configurationClass": "org.apache.camel.component.milvus.MilvusConfiguration", "configurationField": "configuration", "description": "The port to connect to." },
"timeout": { "index": 4, "kind": "property", "displayName": "Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.milvus.MilvusConfiguration", "configurationField": "configuration", "description": "Sets a default timeout for all requests" },
"token": { "index": 5, "kind": "property", "displayName": "Token", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.milvus.MilvusConfiguration", "configurationField": "configuration", "description": "Sets the API key to use for authentication" },
"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": {
"CamelMilvusAction": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "enum": [ "UPSERT", "RETRIEVE", "DELETE" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The action to be performed.", "constantName": "org.apache.camel.component.milvus.Milvus$Headers#ACTION" },
"CamelMilvusOperationID": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation ID.", "constantName": "org.apache.camel.component.milvus.Milvus$Headers#OPERATION_ID" },
"CamelMilvusOperationStatus": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation Status.", "constantName": "org.apache.camel.component.milvus.Milvus$Headers#OPERATION_STATUS" },
"CamelMilvusOperationStatusValue": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation Status Value.", "constantName": "org.apache.camel.component.milvus.Milvus$Headers#OPERATION_STATUS_VALUE" },
"CamelMilvusWithPayload": { "index": 4, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "true", "description": "Include Payload.", "constantName": "org.apache.camel.component.milvus.Milvus$Headers#INCLUDE_PAYLOAD" },
"CamelMilvusWithVectors": { "index": 5, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "false", "description": "Include Vectors.", "constantName": "org.apache.camel.component.milvus.Milvus$Headers#INCLUDE_VECTORS" },
"CamelMilvusSize": { "index": 6, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The number of elements.", "constantName": "org.apache.camel.component.milvus.Milvus$Headers#SIZE" }
},
"properties": {
"collection": { "index": 0, "kind": "path", "displayName": "Collection", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The collection Name" },
"host": { "index": 1, "kind": "parameter", "displayName": "Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "localhost", "configurationClass": "org.apache.camel.component.milvus.MilvusConfiguration", "configurationField": "configuration", "description": "The host to connect to." },
"port": { "index": 2, "kind": "parameter", "displayName": "Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 19530, "configurationClass": "org.apache.camel.component.milvus.MilvusConfiguration", "configurationField": "configuration", "description": "The port to connect to." },
"timeout": { "index": 3, "kind": "parameter", "displayName": "Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.milvus.MilvusConfiguration", "configurationField": "configuration", "description": "Sets a default timeout for all requests" },
"token": { "index": 4, "kind": "parameter", "displayName": "Token", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.milvus.MilvusConfiguration", "configurationField": "configuration", "description": "Sets the API key to use for authentication" },
"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." }
}
}
56 changes: 56 additions & 0 deletions components-starter/camel-milvus-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>components-starter</artifactId>
<version>4.5.0-SNAPSHOT</version>
</parent>
<artifactId>camel-milvus-starter</artifactId>
<packaging>jar</packaging>
<name>Camel SB Starters :: milvus</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-milvus</artifactId>
<version>${camel-version}</version>
<!--START OF GENERATED CODE-->
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<!--END OF GENERATED CODE-->
</dependency>
<!--START OF GENERATED CODE-->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-core-starter</artifactId>
</dependency>
<!--END OF GENERATED CODE-->
</dependencies>
</project>
75 changes: 75 additions & 0 deletions components-starter/camel-milvus-starter/src/main/docs/milvus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"groups": [
{
"name": "camel.component.milvus",
"type": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration"
},
{
"name": "camel.component.milvus.customizer",
"type": "org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration",
"sourceMethod": "getCustomizer()"
}
],
"properties": [
{
"name": "camel.component.milvus.autowired-enabled",
"type": "java.lang.Boolean",
"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.",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration",
"defaultValue": true
},
{
"name": "camel.component.milvus.configuration",
"type": "org.apache.camel.component.milvus.MilvusConfiguration",
"description": "The configuration;. The option is a org.apache.camel.component.milvus.MilvusConfiguration type.",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration"
},
{
"name": "camel.component.milvus.customizer.enabled",
"type": "java.lang.Boolean",
"sourceType": "org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties"
},
{
"name": "camel.component.milvus.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable auto configuration of the milvus component. This is enabled by default.",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration"
},
{
"name": "camel.component.milvus.host",
"type": "java.lang.String",
"description": "The host to connect to.",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration",
"defaultValue": "localhost"
},
{
"name": "camel.component.milvus.lazy-start-producer",
"type": "java.lang.Boolean",
"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.",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration",
"defaultValue": false
},
{
"name": "camel.component.milvus.port",
"type": "java.lang.Integer",
"description": "The port to connect to.",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration",
"defaultValue": 19530
},
{
"name": "camel.component.milvus.timeout",
"type": "java.lang.Long",
"description": "Sets a default timeout for all requests",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration"
},
{
"name": "camel.component.milvus.token",
"type": "java.lang.String",
"description": "Sets the API key to use for authentication",
"sourceType": "org.apache.camel.component.milvus.springboot.MilvusComponentConfiguration"
}
],
"hints": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.component.milvus.springboot;

import org.apache.camel.CamelContext;
import org.apache.camel.Component;
import org.apache.camel.component.milvus.MilvusComponent;
import org.apache.camel.spi.ComponentCustomizer;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.spring.boot.ComponentConfigurationProperties;
import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
import org.apache.camel.spring.boot.util.ConditionalOnHierarchicalProperties;
import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Configuration(proxyBeanMethods = false)
@Conditional(ConditionalOnCamelContextAndAutoConfigurationBeans.class)
@EnableConfigurationProperties({ComponentConfigurationProperties.class,MilvusComponentConfiguration.class})
@ConditionalOnHierarchicalProperties({"camel.component", "camel.component.milvus"})
@AutoConfigureAfter({CamelAutoConfiguration.class, MilvusComponentConverter.class})
public class MilvusComponentAutoConfiguration {

@Autowired
private ApplicationContext applicationContext;
private final CamelContext camelContext;
@Autowired
private MilvusComponentConfiguration configuration;

public MilvusComponentAutoConfiguration(
org.apache.camel.CamelContext camelContext) {
this.camelContext = camelContext;
}

@Lazy
@Bean
public ComponentCustomizer configureMilvusComponent() {
return new ComponentCustomizer() {
@Override
public void configure(String name, Component target) {
CamelPropertiesHelper.copyProperties(camelContext, configuration, target);
}
@Override
public boolean isEnabled(String name, Component target) {
return HierarchicalPropertiesEvaluator.evaluate(
applicationContext,
"camel.component.customizer",
"camel.component.milvus.customizer")
&& target instanceof MilvusComponent;
}
};
}
}
Loading

0 comments on commit 4eb78e0

Please sign in to comment.