You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/08/25 11:53:31 UTC

[GitHub] [camel-quarkus] zhfeng opened a new pull request, #4049: Springless JPA extension

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

   - It replaces the spring transaction template with Quarkus TX API
   - It excludes `spring-orm`
   - I have to add some tricks to make it work in native mode
   
   <!-- 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


[GitHub] [camel-quarkus] zhfeng commented on pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#issuecomment-1246289217

   yeah, sure. I'm working the doc.


-- 
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


[GitHub] [camel-quarkus] zhfeng merged pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng merged PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049


-- 
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


[GitHub] [camel-quarkus] ppalaga commented on a diff in pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
ppalaga commented on code in PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#discussion_r969257247


##########
integration-tests/jpa/src/main/java/org/apache/camel/quarkus/component/jpa/it/JpaRoute.java:
##########
@@ -73,7 +77,12 @@ public void configure() throws Exception {
         from("direct:idempotent")
                 .idempotentConsumer(
                         header("messageId"),
-                        jpaMessageIdRepository(entityManagerFactory, "idempotentProcessor"))
+                        new JpaMessageIdRepository(entityManagerFactory, new TransactionStrategy() {
+                            @Override
+                            public void executeInTransaction(Runnable runnable) {
+                                QuarkusTransaction.run(runOptions().semantic(RunOptions.Semantic.JOIN_EXISTING), runnable);
+                            }
+                        }, "idempotentProcessor"))

Review Comment:
   Will end users always have to create the `JpaMessageIdRepository` like this? If so, can't we automate it for them somehow? Or at least document that they need to do this?



-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on code in PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#discussion_r970255785


##########
integration-tests/jpa/src/main/java/org/apache/camel/quarkus/component/jpa/it/JpaRoute.java:
##########
@@ -73,7 +77,12 @@ public void configure() throws Exception {
         from("direct:idempotent")
                 .idempotentConsumer(
                         header("messageId"),
-                        jpaMessageIdRepository(entityManagerFactory, "idempotentProcessor"))
+                        new JpaMessageIdRepository(entityManagerFactory, new TransactionStrategy() {
+                            @Override
+                            public void executeInTransaction(Runnable runnable) {
+                                QuarkusTransaction.run(runOptions().semantic(RunOptions.Semantic.JOIN_EXISTING), runnable);
+                            }
+                        }, "idempotentProcessor"))

Review Comment:
   Done



-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on code in PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#discussion_r970254479


##########
extensions/jpa/runtime/pom.xml:
##########
@@ -44,14 +49,14 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-core</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-support-spring</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-jpa</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>

Review Comment:
   Finnaly we remove it! and add fake `PlatformTransactionManager` and `TransactionTemplate` to make it work with graalvm native bulding.



-- 
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


[GitHub] [camel-quarkus] jamesnetherton commented on a diff in pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on code in PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#discussion_r954949601


##########
extensions/jpa/runtime/pom.xml:
##########
@@ -44,14 +49,14 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-core</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-support-spring</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-jpa</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>

Review Comment:
   Could maybe scope as `provided`?
   
   Not sure if it'd be possible eventually to remove this entirely. It'd be nice if we could.



##########
extensions/jpa/runtime/src/main/java/org/apache/camel/quarkus/component/jpa/DefaultTransactionStrategySubstitution.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.jpa;
+
+import javax.persistence.EntityManagerFactory;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.camel.component.jpa.DefaultTransactionStrategy;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.support.TransactionTemplate;
+
+@TargetClass(DefaultTransactionStrategy.class)
+final public class DefaultTransactionStrategySubstitution {

Review Comment:
   I wonder if we could annotate this class with `@Delete` instead of doing the method substitutions? If we are forcing the transaction strategy in the extension, then in theory there should be nothing that needs access to it.



-- 
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


[GitHub] [camel-quarkus] zhfeng commented on pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#issuecomment-1235217185

   It needs https://github.com/apache/camel/pull/8264 to use TransactionStrategy in `JpaMessageIdRepository`


-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on code in PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#discussion_r969287368


##########
integration-tests/jpa/src/main/java/org/apache/camel/quarkus/component/jpa/it/JpaRoute.java:
##########
@@ -73,7 +77,12 @@ public void configure() throws Exception {
         from("direct:idempotent")
                 .idempotentConsumer(
                         header("messageId"),
-                        jpaMessageIdRepository(entityManagerFactory, "idempotentProcessor"))
+                        new JpaMessageIdRepository(entityManagerFactory, new TransactionStrategy() {
+                            @Override
+                            public void executeInTransaction(Runnable runnable) {
+                                QuarkusTransaction.run(runOptions().semantic(RunOptions.Semantic.JOIN_EXISTING), runnable);
+                            }
+                        }, "idempotentProcessor"))

Review Comment:
   yeah, I think we can add `QuarkusTransactionStrategy`.



-- 
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


[GitHub] [camel-quarkus] zhfeng commented on pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#issuecomment-1245054043

   Thanks @ppalaga only `spring-tx` is used right now and yeah, most of them needed in native to make compiler happy are `PlatformTransactionManager` and `TransactionTemplate`. I'm not sure if it is possible to add fake classes but will try it.


-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on code in PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#discussion_r970255679


##########
extensions/jpa/runtime/src/main/java/org/apache/camel/quarkus/component/jpa/DefaultTransactionStrategySubstitution.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.jpa;
+
+import javax.persistence.EntityManagerFactory;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.camel.component.jpa.DefaultTransactionStrategy;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.support.TransactionTemplate;
+
+@TargetClass(DefaultTransactionStrategy.class)
+final public class DefaultTransactionStrategySubstitution {

Review Comment:
   It is deleted now.



-- 
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


[GitHub] [camel-quarkus] jamesnetherton commented on pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#issuecomment-1246287573

   Do we need any additional documentation? E.g in the route you inject `TransactionStrategy` and use it in the `JpaMessageIdRepository`. If the same thing is expected by users, then we should add a note into the extension docs.


-- 
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


[GitHub] [camel-quarkus] zhfeng commented on pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#issuecomment-1227158677

   @jamesnetherton @ppalaga please review these changes and I think it might be experimental feature currently. 


-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on code in PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#discussion_r961409650


##########
extensions/jpa/runtime/src/main/java/org/apache/camel/quarkus/component/jpa/DefaultTransactionStrategySubstitution.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.jpa;
+
+import javax.persistence.EntityManagerFactory;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.camel.component.jpa.DefaultTransactionStrategy;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.support.TransactionTemplate;
+
+@TargetClass(DefaultTransactionStrategy.class)
+final public class DefaultTransactionStrategySubstitution {

Review Comment:
   No, graalvm has to find `DefaultTransactionStrategy` during the static analyst phase. 



-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4049: Springless JPA extension

Posted by GitBox <gi...@apache.org>.
zhfeng commented on code in PR #4049:
URL: https://github.com/apache/camel-quarkus/pull/4049#discussion_r961411529


##########
extensions/jpa/runtime/pom.xml:
##########
@@ -44,14 +49,14 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-core</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-support-spring</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-jpa</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>

Review Comment:
   `java.lang.ClassNotFoundException: org.springframework.transaction.support.TransactionTemplate` is throws during static analyst if we add `provided` scope.



-- 
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