You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "JiriOndrusek (via GitHub)" <gi...@apache.org> on 2025/06/04 14:12:42 UTC

[PR] [camel-main] Weaviate extension [camel-quarkus]

JiriOndrusek opened a new pull request, #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420

   fixes https://github.com/apache/camel-quarkus/issues/7259
   
   Extension requires camel 4.13.0. (https://github.com/apache/camel/pull/18272 and https://github.com/apache/camel/pull/18251)
   
   Tests can run  via docker image or against real API. 
   
   <!-- Uncomment and fill this section if your PR is not trivial
   [ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
   [ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
   [ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
   [ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [camel-main] Weaviate extension [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420#discussion_r2127006854


##########
integration-tests/weaviate/src/main/java/org/apache/camel/quarkus/component/weaviate/it/WeaviateResource.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.quarkus.component.weaviate.it;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import io.weaviate.client.base.Result;
+import io.weaviate.client.v1.data.model.WeaviateObject;
+import io.weaviate.client.v1.graphql.model.GraphQLResponse;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.jboss.logging.Logger;
+
+@Path("/weaviate")
+@ApplicationScoped
+public class WeaviateResource {
+
+    public static final String WEAVIATE_CONTAINER_ADDRESS = "cq.weaviate.container.address";
+    public static final String WEAVIATE_API_KEY_ENV = "WEAVIATE_API_KEY";
+    public static final String WEAVIATE_HOST_ENV = "WEAVIATE_HOST";
+
+    private static final Logger LOG = Logger.getLogger(WeaviateResource.class);
+
+    @Inject
+    CamelContext context;
+
+    @ConfigProperty(name = WEAVIATE_CONTAINER_ADDRESS)
+    Optional<String> weaviateContainerAddress;
+
+    @Path("/request")
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response request(Map<String, Object> testHeaders) {
+        Map<String, Object> headers = new HashMap<>(testHeaders);
+
+        Object body = headers.get("body");
+        headers.remove("body");
+
+        //convert Double to Float in body list (for create)
+        if (body instanceof List) {
+            body = ((List<?>) body).stream().map(o -> o instanceof Double ? ((Double) o).floatValue() : o)
+                    .collect(Collectors.toList());
+        }
+
+        Exchange response = context.createFluentProducerTemplate()
+                .to(getUrl())
+                .withBody(body)
+                .withHeaders(headers)
+                .request(Exchange.class);

Review Comment:
   General comment. No need to change things unless you want to. But...
   
   I think it's better to get into the habit of writing actual Camel routes within a `RouteBuilder` class, instead of using the `ProducerTemplate` to send messages directly to the component under test. That way it aligns better with what users are more likely to do in their own apps.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [camel-main] Weaviate extension [camel-quarkus]

Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420#discussion_r2128092067


##########
integration-tests/weaviate/src/main/java/org/apache/camel/quarkus/component/weaviate/it/WeaviateResource.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.quarkus.component.weaviate.it;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import io.weaviate.client.base.Result;
+import io.weaviate.client.v1.data.model.WeaviateObject;
+import io.weaviate.client.v1.graphql.model.GraphQLResponse;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.jboss.logging.Logger;
+
+@Path("/weaviate")
+@ApplicationScoped
+public class WeaviateResource {
+
+    public static final String WEAVIATE_CONTAINER_ADDRESS = "cq.weaviate.container.address";
+    public static final String WEAVIATE_API_KEY_ENV = "WEAVIATE_API_KEY";
+    public static final String WEAVIATE_HOST_ENV = "WEAVIATE_HOST";
+
+    private static final Logger LOG = Logger.getLogger(WeaviateResource.class);
+
+    @Inject
+    CamelContext context;
+
+    @ConfigProperty(name = WEAVIATE_CONTAINER_ADDRESS)
+    Optional<String> weaviateContainerAddress;
+
+    @Path("/request")
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response request(Map<String, Object> testHeaders) {
+        Map<String, Object> headers = new HashMap<>(testHeaders);
+
+        Object body = headers.get("body");
+        headers.remove("body");
+
+        //convert Double to Float in body list (for create)
+        if (body instanceof List) {
+            body = ((List<?>) body).stream().map(o -> o instanceof Double ? ((Double) o).floatValue() : o)
+                    .collect(Collectors.toList());
+        }
+
+        Exchange response = context.createFluentProducerTemplate()
+                .to(getUrl())
+                .withBody(body)
+                .withHeaders(headers)
+                .request(Exchange.class);

Review Comment:
   I understand. TBH I switched from routes to fluent producer and back several time, as I was not able to decide what is better. I'll rework the code to use routes, as your point makes sense to me.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [camel-main] Weaviate extension [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton merged PR #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [camel-main] Weaviate extension [camel-quarkus]

Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420#discussion_r2128092067


##########
integration-tests/weaviate/src/main/java/org/apache/camel/quarkus/component/weaviate/it/WeaviateResource.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.quarkus.component.weaviate.it;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import io.weaviate.client.base.Result;
+import io.weaviate.client.v1.data.model.WeaviateObject;
+import io.weaviate.client.v1.graphql.model.GraphQLResponse;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.jboss.logging.Logger;
+
+@Path("/weaviate")
+@ApplicationScoped
+public class WeaviateResource {
+
+    public static final String WEAVIATE_CONTAINER_ADDRESS = "cq.weaviate.container.address";
+    public static final String WEAVIATE_API_KEY_ENV = "WEAVIATE_API_KEY";
+    public static final String WEAVIATE_HOST_ENV = "WEAVIATE_HOST";
+
+    private static final Logger LOG = Logger.getLogger(WeaviateResource.class);
+
+    @Inject
+    CamelContext context;
+
+    @ConfigProperty(name = WEAVIATE_CONTAINER_ADDRESS)
+    Optional<String> weaviateContainerAddress;
+
+    @Path("/request")
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response request(Map<String, Object> testHeaders) {
+        Map<String, Object> headers = new HashMap<>(testHeaders);
+
+        Object body = headers.get("body");
+        headers.remove("body");
+
+        //convert Double to Float in body list (for create)
+        if (body instanceof List) {
+            body = ((List<?>) body).stream().map(o -> o instanceof Double ? ((Double) o).floatValue() : o)
+                    .collect(Collectors.toList());
+        }
+
+        Exchange response = context.createFluentProducerTemplate()
+                .to(getUrl())
+                .withBody(body)
+                .withHeaders(headers)
+                .request(Exchange.class);

Review Comment:
   I understand. TBH I switched from routes to fluent producer and back several time, as I was not able to decide what is better. I'll rework the code to use routes, as your point make sense to me.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [camel-main] Weaviate extension [camel-quarkus]

Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on PR #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420#issuecomment-2940204678

   @jamesnetherton I'd keep this PR(draft) opened until we merge the camel-main into main, to avoid separating this changes in the camel-main maintenance. WDYT?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [camel-main] Weaviate extension [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on PR #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420#issuecomment-2940679831

   > @jamesnetherton I'd keep this PR(draft) opened until we merge the camel-main into main, to avoid separating this changes in the camel-main maintenance. WDYT?
   
   Yeah, I'm fine with that if it makes life easier to maintain `camel-main`. The alternative might be to move this commit before the Camel upgrade commit. Choose whatever is easier for you.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [camel-main] Weaviate extension [camel-quarkus]

Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420#discussion_r2128198234


##########
integration-tests/weaviate/src/main/java/org/apache/camel/quarkus/component/weaviate/it/WeaviateResource.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.quarkus.component.weaviate.it;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import io.weaviate.client.base.Result;
+import io.weaviate.client.v1.data.model.WeaviateObject;
+import io.weaviate.client.v1.graphql.model.GraphQLResponse;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.jboss.logging.Logger;
+
+@Path("/weaviate")
+@ApplicationScoped
+public class WeaviateResource {
+
+    public static final String WEAVIATE_CONTAINER_ADDRESS = "cq.weaviate.container.address";
+    public static final String WEAVIATE_API_KEY_ENV = "WEAVIATE_API_KEY";
+    public static final String WEAVIATE_HOST_ENV = "WEAVIATE_HOST";
+
+    private static final Logger LOG = Logger.getLogger(WeaviateResource.class);
+
+    @Inject
+    CamelContext context;
+
+    @ConfigProperty(name = WEAVIATE_CONTAINER_ADDRESS)
+    Optional<String> weaviateContainerAddress;
+
+    @Path("/request")
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response request(Map<String, Object> testHeaders) {
+        Map<String, Object> headers = new HashMap<>(testHeaders);
+
+        Object body = headers.get("body");
+        headers.remove("body");
+
+        //convert Double to Float in body list (for create)
+        if (body instanceof List) {
+            body = ((List<?>) body).stream().map(o -> o instanceof Double ? ((Double) o).floatValue() : o)
+                    .collect(Collectors.toList());
+        }
+
+        Exchange response = context.createFluentProducerTemplate()
+                .to(getUrl())
+                .withBody(body)
+                .withHeaders(headers)
+                .request(Exchange.class);

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [camel-main] Weaviate extension [camel-quarkus]

Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on PR #7420:
URL: https://github.com/apache/camel-quarkus/pull/7420#issuecomment-2943143161

   Lets merge it, with some re-thinking I don't see this change making maintenance of `camel-main` harder.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org