You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by li...@apache.org on 2021/01/06 02:33:32 UTC

[dubbo-samples] branch master updated: complete dubbo-samples-transaction integration test case (#218)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new f43bf82  complete dubbo-samples-transaction integration test case (#218)
f43bf82 is described below

commit f43bf827a654797751873ef58d59b411b3d767f2
Author: 盛超杰 <sh...@163.com>
AuthorDate: Wed Jan 6 10:33:23 2021 +0800

    complete dubbo-samples-transaction integration test case (#218)
---
 dubbo-samples-transaction/case-configuration.yml   |  10 +
 dubbo-samples-transaction/pom.xml                  | 264 ++-------------------
 .../dubbo/samples/service/BusinessService.java     |   3 +-
 .../samples/service/impl/BusinessServiceImpl.java  |   9 +-
 .../dubbo/samples/starter/DubboBusinessTester.java |   2 +-
 .../src/main/resources/docker/docker-compose.yml   |  13 +-
 .../src/main/resources/docker/mysql/Dockerfile     |   6 -
 .../main/resources/docker/mysql/sql/undo-log.sql   |  14 +-
 .../src/main/resources/docker/seata/Dockerfile     |  12 -
 .../src/main/resources/docker/seata/conf/file.conf |   2 +-
 .../resources/{docker/seata/conf => }/file.conf    |  44 ++--
 .../src/main/resources/jdbc.properties             |   6 +-
 .../src/main/resources/registry.conf               |  51 ++++
 .../resources/spring/dubbo-account-service.xml     |   2 +-
 .../src/main/resources/spring/dubbo-business.xml   |   2 +-
 .../main/resources/spring/dubbo-order-service.xml  |   2 +-
 .../resources/spring/dubbo-storage-service.xml     |   2 +-
 .../apache/dubbo/samples/service/BusinessIT.java   |  24 +-
 18 files changed, 157 insertions(+), 311 deletions(-)

diff --git a/dubbo-samples-transaction/case-configuration.yml b/dubbo-samples-transaction/case-configuration.yml
index 8420578..67da225 100644
--- a/dubbo-samples-transaction/case-configuration.yml
+++ b/dubbo-samples-transaction/case-configuration.yml
@@ -59,12 +59,15 @@ services:
     systemProps:
       - zookeeper.address=zookeeper
       - zookeeper.port=2181
+      - seata.address=seata-server:8091
     waitPortsBeforeRun:
       - zookeeper:2181
+      - seata-mysql:3306
     expose:
       - 20882
     depends_on:
       - seata-mysql
+      - seata-server
 
   account-service:
     type: app
@@ -73,12 +76,15 @@ services:
     systemProps:
       - zookeeper.address=zookeeper
       - zookeeper.port=2181
+      - seata.address=seata-server:8091
     waitPortsBeforeRun:
       - zookeeper:2181
+      - seata-mysql:3306
     expose:
       - 20881
     depends_on:
       - seata-mysql
+      - seata-server
 
   order-service:
     type: app
@@ -87,12 +93,15 @@ services:
     systemProps:
       - zookeeper.address=zookeeper
       - zookeeper.port=2181
+      - seata.address=seata-server:8091
     waitPortsBeforeRun:
       - zookeeper:2181
+      - seata-mysql:3306
     expose:
       - 20883
     depends_on:
       - seata-mysql
+      - seata-server
 
   transaction-test:
     type: test
@@ -102,6 +111,7 @@ services:
     systemProps:
       - zookeeper.address=zookeeper
       - zookeeper.port=2181
+      - seata.address=seata-server:8091
     waitPortsBeforeRun:
       - zookeeper:2181
       - storage-service:20882
diff --git a/dubbo-samples-transaction/pom.xml b/dubbo-samples-transaction/pom.xml
index 376cbd0..ee6b5c4 100644
--- a/dubbo-samples-transaction/pom.xml
+++ b/dubbo-samples-transaction/pom.xml
@@ -32,25 +32,34 @@
         <source.level>1.8</source.level>
         <target.level>1.8</target.level>
         <dubbo.version>2.7.7</dubbo.version>
-        <seata.version>0.5.0</seata.version>
-        <mysql-connector.version>8.0.15</mysql-connector.version>
+        <seata.version>1.4.0</seata.version>
         <spring.version>4.3.16.RELEASE</spring.version>
         <junit.version>4.12</junit.version>
-        <docker-maven-plugin.version>0.30.0</docker-maven-plugin.version>
-        <jib-maven-plugin.version>1.2.0</jib-maven-plugin.version>
         <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
-        <maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
     </properties>
 
     <dependencyManagement>
         <dependencies>
             <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-framework-bom</artifactId>
+                <version>${spring.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
                 <groupId>org.apache.dubbo</groupId>
-                <artifactId>dubbo-dependencies-bom</artifactId>
+                <artifactId>dubbo-bom</artifactId>
                 <version>${dubbo.version}</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-dependencies-zookeeper</artifactId>
+                <version>${dubbo.version}</version>
+                <type>pom</type>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -58,44 +67,36 @@
         <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo</artifactId>
-            <version>${dubbo.version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-dependencies-zookeeper</artifactId>
-            <version>${dubbo.version}</version>
             <type>pom</type>
         </dependency>
 
         <dependency>
             <groupId>io.seata</groupId>
-            <artifactId>seata-spring</artifactId>
+            <artifactId>seata-all</artifactId>
             <version>${seata.version}</version>
         </dependency>
 
+        <!-- fix  the fifth problem in https://shirenchuang.blog.csdn.net/article/details/106739176 -->
         <dependency>
-            <groupId>io.seata</groupId>
-            <artifactId>seata-dubbo</artifactId>
-            <version>${seata.version}</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.dubbo</groupId>
-                    <artifactId>dubbo</artifactId>
-                </exclusion>
-            </exclusions>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.11.0</version>
         </dependency>
 
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-jdbc</artifactId>
-            <version>${spring.version}</version>
         </dependency>
 
         <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
-            <version>${mysql-connector.version}</version>
+            <version>8.0.15</version>
         </dependency>
 
         <dependency>
@@ -108,234 +109,13 @@
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
-            <version>${spring.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
 
-    <profiles>
-        <profile>
-            <id>dubbo-integration-test-disabled</id>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.apache.dubbo</groupId>
-                        <artifactId>dubbo-maven-address-plugin</artifactId>
-                        <version>1.0-SNAPSHOT</version>
-                        <executions>
-                            <execution>
-                                <goals>
-                                    <goal>local-address</goal>
-                                </goals>
-                                <configuration>
-                                    <localAddress>dubbo-local-address</localAddress>
-                                </configuration>
-                                <phase>initialize</phase>
-                            </execution>
-                        </executions>
-                    </plugin>
-
-
-                    <plugin>
-                        <groupId>io.fabric8</groupId>
-                        <artifactId>docker-maven-plugin</artifactId>
-                        <version>${docker-maven-plugin.version}</version>
-                        <configuration>
-                            <images>
-                                <image>
-                                    <name>transaction-mysql</name>
-                                    <build>
-                                        <contextDir>${project.basedir}/src/main/resources/docker/mysql</contextDir>
-                                    </build>
-                                    <run>
-                                        <ports>
-                                            <port>3306:3306</port>
-                                        </ports>
-                                        <wait>
-                                            <log>.*ready for connections.*</log>
-                                            <time>30000</time>
-                                        </wait>
-                                    </run>
-                                </image>
-
-                                <image>
-                                    <name>transaction-seata</name>
-                                    <build>
-                                        <contextDir>${project.basedir}/src/main/resources/docker/seata</contextDir>
-                                    </build>
-                                    <run>
-                                        <ports>
-                                            <port>8091:8091</port>
-                                        </ports>
-                                        <wait>
-                                            <log>.*Server started.*</log>
-                                            <time>60000</time>
-                                        </wait>
-                                    </run>
-                                </image>
-
-                                <image>
-                                    <name>zookeeper:latest</name>
-                                    <run>
-                                        <ports>
-                                            <port>2181:2181</port>
-                                        </ports>
-                                        <wait>
-                                            <tcp>
-                                                <host>${dubbo-local-address}</host>
-                                                <ports>
-                                                    <port>2181</port>
-                                                </ports>
-                                            </tcp>
-                                        </wait>
-                                    </run>
-                                </image>
-                            </images>
-                        </configuration>
-                        <executions>
-                            <execution>
-                                <id>docker-build</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>build</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>start</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>start</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>stop</id>
-                                <phase>post-integration-test</phase>
-                                <goals>
-                                    <goal>stop</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                    </plugin>
-
-                    <plugin>
-                        <groupId>org.codehaus.mojo</groupId>
-                        <artifactId>exec-maven-plugin</artifactId>
-                        <version>1.6.0</version>
-                        <executions>
-                            <execution>
-                                <id>storage-service</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>exec</goal>
-                                </goals>
-                                <configuration>
-                                    <executable>java</executable>
-                                    <arguments>
-                                        <argument>-classpath</argument>
-                                        <classpath/>
-                                        <argument>org.apache.dubbo.samples.starter.DubboStorageServiceStarter</argument>
-                                    </arguments>
-                                    <async>true</async>
-                                    <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
-                                </configuration>
-                            </execution>
 
-                            <execution>
-                                <id>account-service</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>exec</goal>
-                                </goals>
-                                <configuration>
-                                    <executable>java</executable>
-                                    <arguments>
-                                        <argument>-classpath</argument>
-                                        <classpath/>
-                                        <argument>org.apache.dubbo.samples.starter.DubboAccountServiceStarter</argument>
-                                    </arguments>
-                                    <async>true</async>
-                                    <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
-                                </configuration>
-                            </execution>
 
-                            <execution>
-                                <id>order-service</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>exec</goal>
-                                </goals>
-                                <configuration>
-                                    <executable>java</executable>
-                                    <arguments>
-                                        <argument>-classpath</argument>
-                                        <classpath/>
-                                        <argument>org.apache.dubbo.samples.starter.DubboOrderServiceStarter</argument>
-                                    </arguments>
-                                    <async>true</async>
-                                    <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
-                                </configuration>
-                            </execution>
-
-                            <execution>
-                                <id>sleep</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>exec</goal>
-                                </goals>
-                                <configuration>
-                                    <executable>sleep</executable>
-                                    <arguments>
-                                        <argument>10</argument>
-                                    </arguments>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-antrun-plugin</artifactId>
-                        <version>1.8</version>
-                        <executions>
-                            <execution>
-                                <id>kill-process</id>
-                                <phase>post-integration-test</phase>
-                                <configuration>
-                                    <target name="ending">
-                                        <echo>kill dubbo applications</echo>
-                                        <exec executable="bash" spawn="true" dir="${project.basedir}/..">
-                                            <arg value="killall.sh"/>
-                                        </exec>
-                                    </target>
-                                </configuration>
-                                <goals>
-                                    <goal>run</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                    </plugin>
-
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-failsafe-plugin</artifactId>
-                        <version>${maven-failsafe-plugin.version}</version>
-                        <executions>
-                            <execution>
-                                <goals>
-                                    <goal>integration-test</goal>
-                                    <goal>verify</goal>
-                                </goals>
-                                <configuration>
-                                    <includes>
-                                        <include>**/*IT.java</include>
-                                    </includes>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
+    <profiles>
         <!-- For jdk 11 above JavaEE annotation -->
         <profile>
             <id>javax.annotation</id>
diff --git a/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/service/BusinessService.java b/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/service/BusinessService.java
index f6c6258..bb3c5a7 100644
--- a/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/service/BusinessService.java
+++ b/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/service/BusinessService.java
@@ -28,6 +28,7 @@ public interface BusinessService {
      * @param userId        user id
      * @param commodityCode commodity code
      * @param orderCount    order amount
+     * @param needRollback  test rollback and commit feature
      */
-    void purchase(String userId, String commodityCode, int orderCount);
+    void purchase(String userId, String commodityCode, int orderCount , Boolean needRollback);
 }
diff --git a/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/service/impl/BusinessServiceImpl.java b/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/service/impl/BusinessServiceImpl.java
index 2d6be81..bbca728 100644
--- a/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/service/impl/BusinessServiceImpl.java
+++ b/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/service/impl/BusinessServiceImpl.java
@@ -27,6 +27,8 @@ import org.apache.dubbo.samples.service.StorageService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Objects;
+
 public class BusinessServiceImpl implements BusinessService {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
@@ -36,12 +38,13 @@ public class BusinessServiceImpl implements BusinessService {
 
     @Override
     @GlobalTransactional(timeoutMills = 300000, name = "dubbo-demo-tx")
-    public void purchase(String userId, String commodityCode, int orderCount) {
+    public void purchase(String userId, String commodityCode, int orderCount, Boolean needRollback) {
         LOGGER.info("purchase begin ... xid: " + RootContext.getXID());
         storageService.deduct(commodityCode, orderCount);
         orderService.create(userId, commodityCode, orderCount);
-        throw new RuntimeException("xxx");
-
+        if (needRollback) {
+            throw new RuntimeException("xxx");
+        }
     }
 
     /**
diff --git a/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/starter/DubboBusinessTester.java b/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/starter/DubboBusinessTester.java
index fa97703..1cce875 100644
--- a/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/starter/DubboBusinessTester.java
+++ b/dubbo-samples-transaction/src/main/java/org/apache/dubbo/samples/starter/DubboBusinessTester.java
@@ -36,6 +36,6 @@ public class DubboBusinessTester {
          */
         ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-business.xml");
         final BusinessService business = (BusinessService) context.getBean("business");
-        business.purchase("U100001", "C00321", 2);
+        business.purchase("U100001", "C00321", 2, false);
     }
 }
diff --git a/dubbo-samples-transaction/src/main/resources/docker/docker-compose.yml b/dubbo-samples-transaction/src/main/resources/docker/docker-compose.yml
index d9db4f5..9239675 100644
--- a/dubbo-samples-transaction/src/main/resources/docker/docker-compose.yml
+++ b/dubbo-samples-transaction/src/main/resources/docker/docker-compose.yml
@@ -1,13 +1,22 @@
 version: '3.3'
 services:
   seata-mysql:
-    build: mysql
+    image: mysql:5.7
+    volumes:
+      - ./mysql/sql:/docker-entrypoint-initdb.d
+    environment:
+      - MYSQL_DATABASE=seata-demo
+      - MYSQL_ROOT_PASSWORD=helloworld
     ports:
       - "3306:3306"
   seata-server:
-    build: seata
+    image: seataio/seata-server:latest
+    volumes:
+      - ./seata/conf:/root/seata-config
     ports:
       - "8091:8091"
+    depends_on:
+      - seata-mysql
   zookeeper:
     image: "zookeeper:latest"
     ports:
diff --git a/dubbo-samples-transaction/src/main/resources/docker/mysql/Dockerfile b/dubbo-samples-transaction/src/main/resources/docker/mysql/Dockerfile
deleted file mode 100644
index abdcb13..0000000
--- a/dubbo-samples-transaction/src/main/resources/docker/mysql/Dockerfile
+++ /dev/null
@@ -1,6 +0,0 @@
-FROM mysql
-
-ENV MYSQL_DATABASE seata-demo
-ENV MYSQL_ROOT_PASSWORD helloworld
-
-COPY sql /docker-entrypoint-initdb.d/
diff --git a/dubbo-samples-transaction/src/main/resources/docker/mysql/sql/undo-log.sql b/dubbo-samples-transaction/src/main/resources/docker/mysql/sql/undo-log.sql
index 83bcb61..114ca32 100644
--- a/dubbo-samples-transaction/src/main/resources/docker/mysql/sql/undo-log.sql
+++ b/dubbo-samples-transaction/src/main/resources/docker/mysql/sql/undo-log.sql
@@ -1,15 +1,13 @@
 CREATE TABLE `undo_log`
 (
-    `id`            bigint(20)   NOT NULL AUTO_INCREMENT,
-    `branch_id`     bigint(20)   NOT NULL,
+    `id`            bigint(20) NOT NULL AUTO_INCREMENT,
+    `branch_id`     bigint(20) NOT NULL,
     `xid`           varchar(100) NOT NULL,
+    `context`       varchar(128) NOT NULL,
     `rollback_info` longblob     NOT NULL,
-    `log_status`    int(11)      NOT NULL,
+    `log_status`    int(11) NOT NULL,
     `log_created`   datetime     NOT NULL,
     `log_modified`  datetime     NOT NULL,
-    `ext`           varchar(100) DEFAULT NULL,
     PRIMARY KEY (`id`),
-    UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
-) ENGINE = InnoDB
-  AUTO_INCREMENT = 1
-  DEFAULT CHARSET = utf8;
+    UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/dubbo-samples-transaction/src/main/resources/docker/seata/Dockerfile b/dubbo-samples-transaction/src/main/resources/docker/seata/Dockerfile
deleted file mode 100644
index dd4377b..0000000
--- a/dubbo-samples-transaction/src/main/resources/docker/seata/Dockerfile
+++ /dev/null
@@ -1,12 +0,0 @@
-FROM openjdk:8-jre-alpine
-
-RUN mkdir -p /seata
-WORKDIR /seata
-
-RUN wget -U "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" https://github.com/seata/seata/releases/download/0.5.0/seata-server-0.5.0.zip \
-&& unzip seata-server-0.5.0.zip
-
-COPY ./conf/ /seata/conf
-
-EXPOSE 8091
-CMD ["/bin/sh", "/seata/bin/seata-server.sh"]
diff --git a/dubbo-samples-transaction/src/main/resources/docker/seata/conf/file.conf b/dubbo-samples-transaction/src/main/resources/docker/seata/conf/file.conf
index a38ab36..f718dab 100644
--- a/dubbo-samples-transaction/src/main/resources/docker/seata/conf/file.conf
+++ b/dubbo-samples-transaction/src/main/resources/docker/seata/conf/file.conf
@@ -23,7 +23,7 @@ transport {
 
 service {
   #vgroup->rgroup
-  vgroup_mapping.my_test_tx_group = "default"
+  vgroupMapping.my_test_tx_group = "default"
   #only support single node
   default.grouplist = "127.0.0.1:8091"
   #degrade current not support
diff --git a/dubbo-samples-transaction/src/main/resources/docker/seata/conf/file.conf b/dubbo-samples-transaction/src/main/resources/file.conf
similarity index 59%
copy from dubbo-samples-transaction/src/main/resources/docker/seata/conf/file.conf
copy to dubbo-samples-transaction/src/main/resources/file.conf
index a38ab36..2ca7970 100644
--- a/dubbo-samples-transaction/src/main/resources/docker/seata/conf/file.conf
+++ b/dubbo-samples-transaction/src/main/resources/file.conf
@@ -20,12 +20,27 @@ transport {
     worker-thread-size = 8
   }
 }
+store {
+  # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
+  max-branch-session-size = 16384
+  # globe session size , if exceeded throws exceptions
+  max-global-session-size = 512
+  # file buffer size , if exceeded allocate new buffer
+  file-write-buffer-cache-size = 16384
+  # when recover batch read size
+  session.reload.read_size = 100
+}
+
+service-parent {
+    default.grouplist = "127.0.0.1:8091"
+}
+service = ${service-parent}
 
-service {
+service = {
   #vgroup->rgroup
-  vgroup_mapping.my_test_tx_group = "default"
+  vgroupMapping.my_test_tx_group = "default"
   #only support single node
-  default.grouplist = "127.0.0.1:8091"
+  default.grouplist = ${?seata.address}
   #degrade current not support
   enableDegrade = false
   #disable
@@ -38,26 +53,5 @@ client {
     retry.internal = 10
     retry.times = 30
   }
+  report.retry.count = 5
 }
-
-
-## transaction log store
-store {
-  ## store mode: file、db
-  mode = "file"
-
-  ## file store
-  file {
-    dir = "file_store/dubbo"
-
-    # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
-    max-branch-session-size = 16384
-    # globe session size , if exceeded throws exceptions
-    max-global-session-size = 512
-    # file buffer size , if exceeded allocate new buffer
-    file-write-buffer-cache-size = 16384
-    # when recover batch read size
-    session.reload.read_size = 100
-  }
-}
-
diff --git a/dubbo-samples-transaction/src/main/resources/jdbc.properties b/dubbo-samples-transaction/src/main/resources/jdbc.properties
index 03d2dda..a0b5b85 100644
--- a/dubbo-samples-transaction/src/main/resources/jdbc.properties
+++ b/dubbo-samples-transaction/src/main/resources/jdbc.properties
@@ -13,17 +13,17 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 #
-jdbc.account.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata-demo
+jdbc.account.url=jdbc:mysql://${mysql.address:127.0.0.1}:${mysql.port:3306}/seata-demo
 jdbc.account.username=root
 jdbc.account.password=helloworld
 jdbc.account.driver=com.mysql.jdbc.Driver
 # storage db config
-jdbc.storage.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata-demo
+jdbc.storage.url=jdbc:mysql://${mysql.address:127.0.0.1}:${mysql.port:3306}/seata-demo
 jdbc.storage.username=root
 jdbc.storage.password=helloworld
 jdbc.storage.driver=com.mysql.jdbc.Driver
 # order db config
-jdbc.order.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata-demo
+jdbc.order.url=jdbc:mysql://${mysql.address:127.0.0.1}:${mysql.port:3306}/seata-demo
 jdbc.order.username=root
 jdbc.order.password=helloworld
 jdbc.order.driver=com.mysql.jdbc.Driver
diff --git a/dubbo-samples-transaction/src/main/resources/registry.conf b/dubbo-samples-transaction/src/main/resources/registry.conf
new file mode 100644
index 0000000..fa9a4da
--- /dev/null
+++ b/dubbo-samples-transaction/src/main/resources/registry.conf
@@ -0,0 +1,51 @@
+registry {
+  # file 、nacos 、eureka、redis、zk
+  type = "file"
+
+  nacos {
+    serverAddr = "localhost"
+    namespace = "public"
+    cluster = "default"
+  }
+  eureka {
+    serviceUrl = "http://localhost:1001/eureka"
+    application = "default"
+    weight = "1"
+  }
+  redis {
+    serverAddr = "localhost:6379"
+    db = "0"
+  }
+  zk {
+    cluster = "default"
+    serverAddr = "127.0.0.1:2181"
+    session.timeout = 6000
+    connect.timeout = 2000
+  }
+  file {
+    name = "file.conf"
+  }
+}
+
+config {
+  # file、nacos 、apollo、zk
+  type = "file"
+
+  nacos {
+    serverAddr = "localhost"
+    namespace = "public"
+    cluster = "default"
+  }
+  apollo {
+    app.id = "fescar-server"
+    apollo.meta = "http://192.168.1.204:8801"
+  }
+  zk {
+    serverAddr = "127.0.0.1:2181"
+    session.timeout = 6000
+    connect.timeout = 2000
+  }
+  file {
+    name = "file.conf"
+  }
+}
diff --git a/dubbo-samples-transaction/src/main/resources/spring/dubbo-account-service.xml b/dubbo-samples-transaction/src/main/resources/spring/dubbo-account-service.xml
index 96bfa98..dba86ec 100644
--- a/dubbo-samples-transaction/src/main/resources/spring/dubbo-account-service.xml
+++ b/dubbo-samples-transaction/src/main/resources/spring/dubbo-account-service.xml
@@ -56,7 +56,7 @@
     </bean>
 
     <dubbo:application name="dubbo-demo-account-service"/>
-    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181" />
+    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}" />
     <dubbo:protocol name="dubbo" port="20881"/>
     <dubbo:service interface="org.apache.dubbo.samples.service.AccountService" ref="service" timeout="10000"/>
 
diff --git a/dubbo-samples-transaction/src/main/resources/spring/dubbo-business.xml b/dubbo-samples-transaction/src/main/resources/spring/dubbo-business.xml
index 665f9c1..c9c3adf 100644
--- a/dubbo-samples-transaction/src/main/resources/spring/dubbo-business.xml
+++ b/dubbo-samples-transaction/src/main/resources/spring/dubbo-business.xml
@@ -24,7 +24,7 @@
                         http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
 
     <dubbo:application name="dubbo-demo-app"/>
-    <dubbo:registry address="zookeeper://localhost:2181" />
+    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}" />
     <dubbo:reference id="orderService" check="false" interface="org.apache.dubbo.samples.service.OrderService"/>
     <dubbo:reference id="storageService" check="false" interface="org.apache.dubbo.samples.service.StorageService"/>
 
diff --git a/dubbo-samples-transaction/src/main/resources/spring/dubbo-order-service.xml b/dubbo-samples-transaction/src/main/resources/spring/dubbo-order-service.xml
index 100e018..c616db0 100644
--- a/dubbo-samples-transaction/src/main/resources/spring/dubbo-order-service.xml
+++ b/dubbo-samples-transaction/src/main/resources/spring/dubbo-order-service.xml
@@ -56,7 +56,7 @@
     </bean>
 
     <dubbo:application name="dubbo-demo-order-service"/>
-    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181" />
+    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}" />
     <dubbo:protocol name="dubbo" port="20883"/>
     <dubbo:service interface="org.apache.dubbo.samples.service.OrderService" ref="service" timeout="10000"/>
 
diff --git a/dubbo-samples-transaction/src/main/resources/spring/dubbo-storage-service.xml b/dubbo-samples-transaction/src/main/resources/spring/dubbo-storage-service.xml
index 56c739c..6cbe935 100644
--- a/dubbo-samples-transaction/src/main/resources/spring/dubbo-storage-service.xml
+++ b/dubbo-samples-transaction/src/main/resources/spring/dubbo-storage-service.xml
@@ -56,7 +56,7 @@
     </bean>
 
     <dubbo:application name="dubbo-demo-storage-service"/>
-    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
     <dubbo:protocol name="dubbo" port="20882"/>
     <dubbo:service interface="org.apache.dubbo.samples.service.StorageService" ref="service" timeout="10000"/>
 
diff --git a/dubbo-samples-transaction/src/test/java/org/apache/dubbo/samples/service/BusinessIT.java b/dubbo-samples-transaction/src/test/java/org/apache/dubbo/samples/service/BusinessIT.java
index 10354a5..07cf50e 100644
--- a/dubbo-samples-transaction/src/test/java/org/apache/dubbo/samples/service/BusinessIT.java
+++ b/dubbo-samples-transaction/src/test/java/org/apache/dubbo/samples/service/BusinessIT.java
@@ -17,9 +17,13 @@
 
 package org.apache.dubbo.samples.service;
 
+import io.seata.config.Configuration;
+import io.seata.config.ConfigurationFactory;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.test.context.ContextConfiguration;
@@ -30,6 +34,9 @@ import static org.junit.Assert.fail;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:/spring/dubbo-business.xml"})
 public class BusinessIT {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(BusinessIT.class);
+
     @Autowired
     @Qualifier("business")
     private BusinessService business;
@@ -41,17 +48,28 @@ public class BusinessIT {
     public void testRollback() throws Exception {
         int before = storageService.queryCount("C00321");
         try {
-            business.purchase("U100001", "C00321", 2);
+            business.purchase("U100001", "C00321", 2, true);
             fail("BusinessService.purchase should throw exception.");
-        } catch (Throwable t) {
+        } catch (RuntimeException t) {
             // ignore
+            LOGGER.error("existing exception..", t);
         }
         int after = storageService.queryCount("C00321");
         Assert.assertEquals(before, after);
     }
 
+    public static final Configuration configuration = ConfigurationFactory.getInstance();
+
     @Test
     public void testCommit() throws Exception {
-        // TODO: need implement a success commit
+        int before = storageService.queryCount("C00321");
+        try {
+            business.purchase("U100001", "C00321", 2, false);
+        } catch (Throwable t) {
+            LOGGER.error("existing exception..", t);
+            fail("BusinessService.purchase should not throw exception.");
+        }
+        int after = storageService.queryCount("C00321");
+        Assert.assertEquals(before - 2, after);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org