From 471a1228fff74822f4d42432fbc2089b5a262ce0 Mon Sep 17 00:00:00 2001 From: slievrly Date: Tue, 16 Jul 2019 13:21:38 +0800 Subject: [PATCH] upgrade seata to 0.7.1 and update seata sample Signed-off-by: slievrly --- spring-cloud-alibaba-dependencies/pom.xml | 4 +- .../src/main/resources/file.conf | 33 ++++++++---- .../src/main/resources/registry.conf | 27 ++++++++-- .../src/main/resources/file.conf | 51 ++++++++----------- .../src/main/resources/registry.conf | 12 +++-- .../src/main/resources/file.conf | 51 ++++++++----------- .../src/main/resources/registry.conf | 12 +++-- .../seata-example/readme-zh.md | 5 +- .../src/main/resources/file.conf | 51 ++++++++----------- .../src/main/resources/registry.conf | 12 +++-- spring-cloud-alibaba-seata/pom.xml | 2 +- 11 files changed, 145 insertions(+), 115 deletions(-) diff --git a/spring-cloud-alibaba-dependencies/pom.xml b/spring-cloud-alibaba-dependencies/pom.xml index 573dc2c4..57b7ed10 100644 --- a/spring-cloud-alibaba-dependencies/pom.xml +++ b/spring-cloud-alibaba-dependencies/pom.xml @@ -20,7 +20,7 @@ 1.6.2 3.1.0 - 0.5.2 + 0.7.1 1.1.1 0.8.0 1.0.9 @@ -210,7 +210,7 @@ io.seata - seata-spring + seata-all ${seata.version} diff --git a/spring-cloud-alibaba-examples/seata-example/account-service/src/main/resources/file.conf b/spring-cloud-alibaba-examples/seata-example/account-service/src/main/resources/file.conf index b49739a1..fd3d304f 100644 --- a/spring-cloud-alibaba-examples/seata-example/account-service/src/main/resources/file.conf +++ b/spring-cloud-alibaba-examples/seata-example/account-service/src/main/resources/file.conf @@ -19,16 +19,12 @@ transport { #auto default pin or 8 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 + shutdown { + # when destroy server, wait seconds + wait = 3 + } + serialization = "seata" + compressor = "none" } service { #vgroup->rgroup @@ -39,6 +35,9 @@ service { enableDegrade = false #disable disable = false + #unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent + max.commit.retry.timeout = "-1" + max.rollback.retry.timeout = "-1" } client { async.commit.buffer.limit = 10000 @@ -46,4 +45,18 @@ client { retry.internal = 10 retry.times = 30 } + report.retry.count = 5 +} +transaction { + undo.data.validation = true + undo.log.serialization = "jackson" +} + +## metrics settings +metrics { + enabled = false + registry-type = "compact" + # multi exporters use comma divided + exporter-list = "prometheus" + exporter-prometheus-port = 9898 } \ No newline at end of file diff --git a/spring-cloud-alibaba-examples/seata-example/account-service/src/main/resources/registry.conf b/spring-cloud-alibaba-examples/seata-example/account-service/src/main/resources/registry.conf index 31bcace5..6dbeb22b 100644 --- a/spring-cloud-alibaba-examples/seata-example/account-service/src/main/resources/registry.conf +++ b/spring-cloud-alibaba-examples/seata-example/account-service/src/main/resources/registry.conf @@ -1,5 +1,5 @@ registry { - # file 、nacos 、eureka、redis、zk、consul + # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa type = "file" nacos { @@ -8,7 +8,7 @@ registry { cluster = "default" } eureka { - serviceUrl = "http://localhost:1001/eureka" + serviceUrl = "http://localhost:8761/eureka" application = "default" weight = "1" } @@ -26,13 +26,26 @@ registry { cluster = "default" serverAddr = "127.0.0.1:8500" } + etcd3 { + cluster = "default" + serverAddr = "http://localhost:2379" + } + sofa { + serverAddr = "127.0.0.1:9603" + application = "default" + region = "DEFAULT_ZONE" + datacenter = "DefaultDataCenter" + cluster = "default" + group = "SEATA_GROUP" + addressWaitTime = "3000" + } file { name = "file.conf" } } config { - # file、nacos 、apollo、zk + # file、nacos 、apollo、zk、consul、etcd3 type = "file" nacos { @@ -40,8 +53,11 @@ config { namespace = "public" cluster = "default" } + consul { + serverAddr = "127.0.0.1:8500" + } apollo { - app.id = "fescar-server" + app.id = "seata-server" apollo.meta = "http://192.168.1.204:8801" } zk { @@ -49,6 +65,9 @@ config { session.timeout = 6000 connect.timeout = 2000 } + etcd3 { + serverAddr = "http://localhost:2379" + } file { name = "file.conf" } diff --git a/spring-cloud-alibaba-examples/seata-example/business-service/src/main/resources/file.conf b/spring-cloud-alibaba-examples/seata-example/business-service/src/main/resources/file.conf index cb1ab8bb..a766d498 100644 --- a/spring-cloud-alibaba-examples/seata-example/business-service/src/main/resources/file.conf +++ b/spring-cloud-alibaba-examples/seata-example/business-service/src/main/resources/file.conf @@ -19,36 +19,12 @@ transport { #auto default pin or 8 worker-thread-size = 8 } -} -## transaction log store -store { - ## store mode: file、db - mode = "file" - - ## file store - file { - dir = "sessionStore" - - # 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 - # async, sync - flush-disk-mode = async + shutdown { + # when destroy server, wait seconds + wait = 3 } - - ## database store - db { - driver_class = "" - url = "" - user = "" - password = "" - } - + serialization = "seata" + compressor = "none" } service { #vgroup->rgroup @@ -59,6 +35,9 @@ service { enableDegrade = false #disable disable = false + #unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent + max.commit.retry.timeout = "-1" + max.rollback.retry.timeout = "-1" } client { async.commit.buffer.limit = 10000 @@ -66,4 +45,18 @@ client { retry.internal = 10 retry.times = 30 } + report.retry.count = 5 +} +transaction { + undo.data.validation = true + undo.log.serialization = "jackson" +} + +## metrics settings +metrics { + enabled = false + registry-type = "compact" + # multi exporters use comma divided + exporter-list = "prometheus" + exporter-prometheus-port = 9898 } \ No newline at end of file diff --git a/spring-cloud-alibaba-examples/seata-example/business-service/src/main/resources/registry.conf b/spring-cloud-alibaba-examples/seata-example/business-service/src/main/resources/registry.conf index 7d71afaa..6dbeb22b 100644 --- a/spring-cloud-alibaba-examples/seata-example/business-service/src/main/resources/registry.conf +++ b/spring-cloud-alibaba-examples/seata-example/business-service/src/main/resources/registry.conf @@ -8,7 +8,7 @@ registry { cluster = "default" } eureka { - serviceUrl = "http://localhost:1001/eureka" + serviceUrl = "http://localhost:8761/eureka" application = "default" weight = "1" } @@ -45,7 +45,7 @@ registry { } config { - # file、nacos 、apollo、zk + # file、nacos 、apollo、zk、consul、etcd3 type = "file" nacos { @@ -53,6 +53,9 @@ config { namespace = "public" cluster = "default" } + consul { + serverAddr = "127.0.0.1:8500" + } apollo { app.id = "seata-server" apollo.meta = "http://192.168.1.204:8801" @@ -62,7 +65,10 @@ config { session.timeout = 6000 connect.timeout = 2000 } + etcd3 { + serverAddr = "http://localhost:2379" + } file { name = "file.conf" } -} \ No newline at end of file +} diff --git a/spring-cloud-alibaba-examples/seata-example/order-service/src/main/resources/file.conf b/spring-cloud-alibaba-examples/seata-example/order-service/src/main/resources/file.conf index 7213edea..536cc785 100644 --- a/spring-cloud-alibaba-examples/seata-example/order-service/src/main/resources/file.conf +++ b/spring-cloud-alibaba-examples/seata-example/order-service/src/main/resources/file.conf @@ -19,36 +19,12 @@ transport { #auto default pin or 8 worker-thread-size = 8 } -} -## transaction log store -store { - ## store mode: file、db - mode = "file" - - ## file store - file { - dir = "sessionStore" - - # 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 - # async, sync - flush-disk-mode = async + shutdown { + # when destroy server, wait seconds + wait = 3 } - - ## database store - db { - driver_class = "" - url = "" - user = "" - password = "" - } - + serialization = "seata" + compressor = "none" } service { #vgroup->rgroup @@ -59,6 +35,9 @@ service { enableDegrade = false #disable disable = false + #unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent + max.commit.retry.timeout = "-1" + max.rollback.retry.timeout = "-1" } client { async.commit.buffer.limit = 10000 @@ -66,4 +45,18 @@ client { retry.internal = 10 retry.times = 30 } + report.retry.count = 5 +} +transaction { + undo.data.validation = true + undo.log.serialization = "jackson" +} + +## metrics settings +metrics { + enabled = false + registry-type = "compact" + # multi exporters use comma divided + exporter-list = "prometheus" + exporter-prometheus-port = 9898 } \ No newline at end of file diff --git a/spring-cloud-alibaba-examples/seata-example/order-service/src/main/resources/registry.conf b/spring-cloud-alibaba-examples/seata-example/order-service/src/main/resources/registry.conf index 7d71afaa..6dbeb22b 100644 --- a/spring-cloud-alibaba-examples/seata-example/order-service/src/main/resources/registry.conf +++ b/spring-cloud-alibaba-examples/seata-example/order-service/src/main/resources/registry.conf @@ -8,7 +8,7 @@ registry { cluster = "default" } eureka { - serviceUrl = "http://localhost:1001/eureka" + serviceUrl = "http://localhost:8761/eureka" application = "default" weight = "1" } @@ -45,7 +45,7 @@ registry { } config { - # file、nacos 、apollo、zk + # file、nacos 、apollo、zk、consul、etcd3 type = "file" nacos { @@ -53,6 +53,9 @@ config { namespace = "public" cluster = "default" } + consul { + serverAddr = "127.0.0.1:8500" + } apollo { app.id = "seata-server" apollo.meta = "http://192.168.1.204:8801" @@ -62,7 +65,10 @@ config { session.timeout = 6000 connect.timeout = 2000 } + etcd3 { + serverAddr = "http://localhost:2379" + } file { name = "file.conf" } -} \ No newline at end of file +} diff --git a/spring-cloud-alibaba-examples/seata-example/readme-zh.md b/spring-cloud-alibaba-examples/seata-example/readme-zh.md index 9c12eb50..25a09668 100644 --- a/spring-cloud-alibaba-examples/seata-example/readme-zh.md +++ b/spring-cloud-alibaba-examples/seata-example/readme-zh.md @@ -50,6 +50,7 @@ CREATE TABLE `undo_log` ( `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_created` datetime NOT NULL, @@ -101,13 +102,13 @@ CREATE TABLE `account_tbl` ( 进入解压之后的 bin 目录,执行如下命令来启动 ```$shell -sh seata-server.sh $LISTEN_PORT $MODE(file or db) +sh seata-server.sh -p $LISTEN_PORT -m $MODE(file or db) ``` 在这个示例中,采用如下命令来启动 Seata Server ```$shell -sh seata-server.sh 8091 file +sh seata-server.sh -p 8091 -m file ``` **注意** 如果你修改了endpoint且注册中心使用默认file类型,那么记得需要在各个示例工程中的 `file.conf` 文件中,修改 grouplist 的值(当registry.conf 中registry.type 或 config.type 为file 时会读取内部的file节点中的文件名,若type不为file将直接从配置类型的对应元数据的注册配置中心读取数据),推荐大家使用 nacos 作为配置注册中心。 diff --git a/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/resources/file.conf b/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/resources/file.conf index 4699d684..90cb0ede 100644 --- a/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/resources/file.conf +++ b/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/resources/file.conf @@ -19,36 +19,12 @@ transport { #auto default pin or 8 worker-thread-size = 8 } -} -## transaction log store -store { - ## store mode: file、db - mode = "file" - - ## file store - file { - dir = "sessionStore" - - # 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 - # async, sync - flush-disk-mode = async + shutdown { + # when destroy server, wait seconds + wait = 3 } - - ## database store - db { - driver_class = "" - url = "" - user = "" - password = "" - } - + serialization = "seata" + compressor = "none" } service { #vgroup->rgroup @@ -59,6 +35,9 @@ service { enableDegrade = false #disable disable = false + #unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent + max.commit.retry.timeout = "-1" + max.rollback.retry.timeout = "-1" } client { async.commit.buffer.limit = 10000 @@ -66,4 +45,18 @@ client { retry.internal = 10 retry.times = 30 } + report.retry.count = 5 +} +transaction { + undo.data.validation = true + undo.log.serialization = "jackson" +} + +## metrics settings +metrics { + enabled = false + registry-type = "compact" + # multi exporters use comma divided + exporter-list = "prometheus" + exporter-prometheus-port = 9898 } \ No newline at end of file diff --git a/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/resources/registry.conf b/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/resources/registry.conf index 7d71afaa..6dbeb22b 100644 --- a/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/resources/registry.conf +++ b/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/resources/registry.conf @@ -8,7 +8,7 @@ registry { cluster = "default" } eureka { - serviceUrl = "http://localhost:1001/eureka" + serviceUrl = "http://localhost:8761/eureka" application = "default" weight = "1" } @@ -45,7 +45,7 @@ registry { } config { - # file、nacos 、apollo、zk + # file、nacos 、apollo、zk、consul、etcd3 type = "file" nacos { @@ -53,6 +53,9 @@ config { namespace = "public" cluster = "default" } + consul { + serverAddr = "127.0.0.1:8500" + } apollo { app.id = "seata-server" apollo.meta = "http://192.168.1.204:8801" @@ -62,7 +65,10 @@ config { session.timeout = 6000 connect.timeout = 2000 } + etcd3 { + serverAddr = "http://localhost:2379" + } file { name = "file.conf" } -} \ No newline at end of file +} diff --git a/spring-cloud-alibaba-seata/pom.xml b/spring-cloud-alibaba-seata/pom.xml index 3938654f..4989d04e 100644 --- a/spring-cloud-alibaba-seata/pom.xml +++ b/spring-cloud-alibaba-seata/pom.xml @@ -16,7 +16,7 @@ io.seata - seata-spring + seata-all