From bd2057171df887f784c7e26fa89b55a4dd6eca58 Mon Sep 17 00:00:00 2001 From: Pascal Leclercq Date: Mon, 28 Apr 2025 12:04:08 +0200 Subject: [PATCH 1/2] feat(214537): Add separate SB3.4 / LogCloud example to work with 6.0 --- pom.xml | 46 +++++++------------ src/main/java/sample/atomikos/Account.java | 6 +-- .../java/sample/atomikos/AccountService.java | 2 +- .../resources/application-postgres.properties | 17 ------- src/main/resources/application-postgres.yml | 31 +++++++++++++ src/main/resources/application.properties | 13 ------ src/main/resources/application.yml | 28 +++++++++++ .../SampleAtomikosApplicationTests.java | 14 +++--- 8 files changed, 86 insertions(+), 71 deletions(-) delete mode 100644 src/main/resources/application-postgres.properties create mode 100644 src/main/resources/application-postgres.yml delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yml diff --git a/pom.xml b/pom.xml index 4fa260b..0aa5f06 100644 --- a/pom.xml +++ b/pom.xml @@ -6,14 +6,14 @@ org.springframework.boot spring-boot-starter-parent - 2.3.4.RELEASE + 3.4.5 spring-boot-sample-jta-atomikos Spring Boot Atomikos JTA Sample Spring Boot Atomikos JTA Sample - 5.0.108.EVAL + 6.0.115-SNAPSHOT @@ -26,8 +26,9 @@ spring-boot-starter-data-jpa - org.springframework.boot - spring-boot-starter-jta-atomikos + com.atomikos + transactions-spring-boot3.4-starter + ${atomikos.version} org.springframework.boot @@ -58,25 +59,24 @@ transactions-logcloud ${atomikos.version} - - - - com.atomikos - transactions-spring-boot-starter + transactions-spring-boot ${atomikos.version} com.atomikos - transactions-spring-boot + transactions-spring-boot-logcloud + ${atomikos.version} + + + com.atomikos + transactions-remoting-recovery ${atomikos.version} com.atomikos - transactions-spring-boot-logcloud + transactions-remoting ${atomikos.version} @@ -85,7 +85,10 @@ 2.0.1 provided - + + jakarta.xml.bind + jakarta.xml.bind-api + org.springframework.boot spring-boot-autoconfigure @@ -112,19 +115,4 @@ - - - java9+ - - [9,) - - - - jakarta.xml.bind - jakarta.xml.bind-api - 2.3.2 - - - - diff --git a/src/main/java/sample/atomikos/Account.java b/src/main/java/sample/atomikos/Account.java index 4221ebc..5cf000b 100644 --- a/src/main/java/sample/atomikos/Account.java +++ b/src/main/java/sample/atomikos/Account.java @@ -16,9 +16,9 @@ package sample.atomikos; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; @Entity public class Account { diff --git a/src/main/java/sample/atomikos/AccountService.java b/src/main/java/sample/atomikos/AccountService.java index 6cb4fc7..854acc0 100644 --- a/src/main/java/sample/atomikos/AccountService.java +++ b/src/main/java/sample/atomikos/AccountService.java @@ -16,7 +16,7 @@ package sample.atomikos; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; import org.springframework.jms.core.JmsTemplate; import org.springframework.stereotype.Service; diff --git a/src/main/resources/application-postgres.properties b/src/main/resources/application-postgres.properties deleted file mode 100644 index c22a242..0000000 --- a/src/main/resources/application-postgres.properties +++ /dev/null @@ -1,17 +0,0 @@ -spring.artemis.embedded.queues=accounts -spring.jpa.open-in-view=true - -spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true -spring.datasource.url=jdbc:postgresql://localhost:5432/atomikos -spring.datasource.username=atomikos -spring.datasource.password=atomikos -spring.jpa.hibernate.ddl-auto=create-drop - -spring.jta.atomikos.datasource.supports-tm-join=false -spring.jta.atomikos.datasource.unique-resource-name=APP -# allow DDL on startup -spring.jta.atomikos.datasource.local-transaction-mode=true - -#all instances that connect to the same logCloud must use the same name (the one defined in data.sql) -spring.jta.atomikos.properties.transaction-manager-unique-name=logcloud -spring.datasource.continue-on-error=true diff --git a/src/main/resources/application-postgres.yml b/src/main/resources/application-postgres.yml new file mode 100644 index 0000000..66cf626 --- /dev/null +++ b/src/main/resources/application-postgres.yml @@ -0,0 +1,31 @@ +# Conversion to YAML from Properties formar report +# Warnings: +# - The yaml file had comments which are lost in the refactoring! +spring: + artemis: + embedded: + queues: accounts + jpa: + open-in-view: true + properties: + hibernate: + jdbc: + lob: + "[non_contextual_creation]": true + hibernate: + ddl-auto: create-drop + datasource: + url: jdbc:postgresql://localhost:5432/atomikos + username: atomikos + password: atomikos + jta: + atomikos: + datasource: + supports-tm-join: false + unique-resource-name: APP + local-transaction-mode: true + properties: + transaction-manager-unique-name: logcloud + sql: + init: + continue-on-error: true diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 731971d..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,13 +0,0 @@ -spring.artemis.embedded.queues=accounts -spring.jpa.open-in-view=true -spring.datasource.url=jdbc:h2:./logcloud - -spring.jta.atomikos.datasource.unique-resource-name=APP -# allow DDL on starup -spring.jta.atomikos.datasource.local-transaction-mode=true - -#all instances that connect to the same logCloud must use the same name (the one defined in data.sql) -spring.jta.atomikos.properties.transaction-manager-unique-name=logcloud -spring.datasource.continue-on-error=true - -atomikos.properties.transaction-manager-unique-name=logcloud diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..d1bc154 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,28 @@ +# Conversion to YAML from Properties formar report +# Warnings: +# - The yaml file had comments which are lost in the refactoring! +spring: + artemis: + embedded: + queues: accounts + jpa: + open-in-view: true + hibernate: + ddl-auto: update + datasource: + url: jdbc:h2:./logcloud + jta: + atomikos: + datasource: + unique-resource-name: APP + local-transaction-mode: true + properties: + transaction-manager-unique-name: logcloud + sql: + init: + continue-on-error: true + mode: always + +atomikos: + properties: + transaction-manager-unique-name: logcloud diff --git a/src/test/java/sample/atomikos/SampleAtomikosApplicationTests.java b/src/test/java/sample/atomikos/SampleAtomikosApplicationTests.java index 71a25cd..8d655c8 100644 --- a/src/test/java/sample/atomikos/SampleAtomikosApplicationTests.java +++ b/src/test/java/sample/atomikos/SampleAtomikosApplicationTests.java @@ -16,14 +16,14 @@ package sample.atomikos; -import org.assertj.core.api.Condition; -import org.junit.Rule; -import org.junit.Test; -import org.springframework.boot.test.system.OutputCaptureRule; import static org.assertj.core.api.Assertions.assertThat; +import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.system.CapturedOutput; + /** * Basic integration tests for demo application. * @@ -31,13 +31,11 @@ */ public class SampleAtomikosApplicationTests { - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); @Test - public void testTransactionRollback() throws Exception { + public void testTransactionRollback(CapturedOutput capturedOutput) throws Exception { SampleAtomikosApplication.main(new String[] {}); - String output = this.outputCapture.toString(); + String output = capturedOutput.getOut(); assertThat(output).has(substring(1, "---->")); assertThat(output).has(substring(1, "----> josh")); assertThat(output).has(substring(2, "Count is 1")); From 0c367fc161139baced7538a4184e033fd00ff6f2 Mon Sep 17 00:00:00 2001 From: Pascal Leclercq Date: Mon, 28 Apr 2025 12:04:58 +0200 Subject: [PATCH 2/2] feat(214537): Add separate SB3.4 / LogCloud example to work with 6.0 switch to the latest 6.x release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0aa5f06..fa59284 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ Spring Boot Atomikos JTA Sample Spring Boot Atomikos JTA Sample - 6.0.115-SNAPSHOT + 6.0.114