当前位置: 首页 > news >正文

使用的电脑做网站的服务器而的跟地seo排名点击软件

使用的电脑做网站的服务器,而的跟地seo排名点击软件,企业网站建设知乎,不知道我自己的网站的ftp账号我举的例子是:在网上购物时,我们支付后,订单微服务会更新订单状态,同时会远程调用购物车微服务清空购物车,和调用商品微服务完成商品库存减一。 我们曾经说的事务是只能在本微服务完成回滚,意思就是如果过…

我举的例子是:在网上购物时,我们支付后,订单微服务会更新订单状态,同时会远程调用购物车微服务清空购物车,和调用商品微服务完成商品库存减一。

我们曾经说的事务是只能在本微服务完成回滚,意思就是如果过程中出现问题需要回滚,只有更新订单状态 这一操作会回滚,而清空购物车和商品库存减一 这俩操作是远程调用其他微服务的操作,是不能回滚的,所以我们就需要分布式事务来解决这种问题。

Seata:致力于提供高性能和简单易用的分布式事务服务,为用户打造一站式的分布式解决方案。

Seata事务管理中有3个重要角色:

 TC:事务协调者:维护全局和分支事务的状态,协调全局事务提交或回滚。

 TM:事务管理器:定义全局事务范围、开始全局事务、提交或回滚全局事务。

 RM:资源管理器:管理分支事务,与TC交谈以注册分支事务和报告分支事务的状态。

 seata有俩种模式:

 XA:

 

在2.3步之前的操作都是对数据库进行预处理,只有2.3确定全部成功后,才会commit提交。

优点:事务强一致性,满足acid原则;常用数据库都支持,实现简单 没有代码介入。

缺点:在若干个RM执行sql时,需要锁定数据库资源,不同的RM用的时间也不同,若有一个还没执行完,其余的执行完的RM就只能干等着,性能很差;依赖关系型数据库实现事务。

 AT模式:

 与XA模式不同的是:AT模式的1.4步执行sql会立刻提交,在1.4执行sql前会基于数据库信息形成一个快照,如果后面有RM失败,就可以把快照信息写回数据库恢复数据。

缺点:在1.4执行提交后,并且在第二阶段事务失败需要回滚时,期间会有短暂(虽然时间很短)的数据不一致,只满足了最终一致性。

下面我来说一说怎么用Java代码去实现它:

 首先我们需要去下载seata,我用的是docker 部署的,用的是1.5.2版本。我们需要把seata注册到nacos中。

我们写一下seata的配置文件: 这里面你只需要改nacos的地址、账号密码;mysql地址、账号密码。

server:port: 7099spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${user.home}/logs/seata# extend:#   logstash-appender:#     destination: 127.0.0.1:4560#   kafka-appender:#     bootstrap-servers: 127.0.0.1:9092#     topic: logback_to_logstashconsole: #seata控制台的账号密码user:username: seatapassword: seataseata:config:# support: nacos, consul, apollo, zk, etcd3type: file# type: nacos# nacos:#   server-addr: 192.168.1.105:8848#   group : "DEFAULT_GROUP"#   namespace: ""#   dataId: "shared-seata.yaml"#   username: "nacos"#   password: "nacos"registry:# support: nacos, eureka, redis, zk, consul, etcd3, sofatype: nacosnacos:application: seata-serverserver-addr: host.docker.internal:8848 #nacos 地址group: "DEFAULT_GROUP"namespace: ""username: "nacos"password: "nacos"#  server:
#    service-port: 8091 #If not configured, the default is '${server.port} + 1000'security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/loginserver:# service-port: 8091 #If not configured, the default is '${server.port} + 1000'max-commit-retry-timeout: -1max-rollback-retry-timeout: -1rollback-retry-timeout-unlock-enable: falseenable-check-auth: trueenable-parallel-request-handle: trueretry-dead-threshold: 130000xaer-nota-retry-timeout: 60000enableParallelRequestHandle: truerecovery:committing-retry-period: 1000async-committing-retry-period: 1000rollbacking-retry-period: 1000timeout-retry-period: 1000undo:log-save-days: 7log-delete-period: 86400000session:branch-async-queue-size: 5000 #branch async remove queue sizeenable-branch-async-remove: false #enable to asynchronous remove branchSessionstore:# support: file 、 db 、 redismode: dbsession:mode: dblock:mode: dbdb:datasource: druiddb-type: mysqldriver-class-name: com.mysql.cj.jdbc.Driver#数据库地址url: jdbc:mysql://mysql:3306/seata?rewriteBatchedStatements=true&serverTimezone=UTCuser: rootpassword: 123min-conn: 10max-conn: 100global-table: global_tablebranch-table: branch_tablelock-table: lock_tabledistributed-lock-table: distributed_lockquery-limit: 1000max-wait: 5000# redis:#   mode: single#   database: 0#   min-conn: 10#   max-conn: 100#   password:#   max-total: 100#   query-limit: 1000#   single:#     host: 192.168.150.101#     port: 6379metrics:enabled: falseregistry-type: compactexporter-list: prometheusexporter-prometheus-port: 9898bindIpAddr: ${SERVICE_BIND_IP}transport:rpc-tc-request-timeout: 15000enable-tc-server-batch-send-response: falseshutdown:wait: 3thread-factory:boss-thread-prefix: NettyBossworker-thread-prefix: NettyServerNIOWorkerboss-thread-size: 1

然后docker启动: 其中SEATA_IP最好与你的nacos启动地址一致,这里查看nacos地址:

如果你nacos和mysql也是用docker部署的,就一定要让它们三个加入同一network。

docker run --name seata -p 8099:8099 -p 7099:7099 -e SEATA_IP=注册到nacos中的地址 -v 你的配置文件的目录:/seata-server/resources --privileged=true --network 你的network名称 -d seataio/seata-server:1.5.2

启动成功后,我们就可以在nacos中看到我们的seata服务:

 然后我们需要在nacos中写一些配置来让我们的微服务能注册到seata中:

seata:registry:  #TC服务中心的配置,微服务根据这些配置去注册中心获取TC服务地址type: nacosnacos: server-addr: 127.0.0.1:8848namespace: ""group: DEFAULT_GROUPapplication: seata-serverusername: nacospassword: nacos#   事务组名称tx-service-group: hmall    service:vgroup-mapping:  # 事务组与tc集群的映射关系hmall: "default"grouplist: default: 127.0.0.1:8099#data-source-proxy-mode: XA   #不填,默认就是AT

然后我们就可以去稍微改一改我们的Java代码了:

首先为我们的购物车微服务、订单微服务、商品微服务添加seata依赖:

        <dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-seata</artifactId></dependency>

还要在这三个微服务的配置文件中导入nacos中的seata配置: 

spring:application:name: ***  # 服务名称profiles:active: dev # 开发环境cloud:nacos:server-addr: localhost:8848 # nacos地址config:file-extension: yamlshared-configs: #seata配置 - data-id: shared-seata.yamldiscovery:cluster-name: public

 

在网上购物时,我们支付后,订单微服务会更新订单状态,同时会远程调用购物车微服务清空购物车,和调用商品微服务完成商品库存减一。   这一操作是订单微服务中的方法,找到改service层方法加上@GlobalTransactional注解

    @Override@GlobalTransactionalpublic Long createOrder(OrderFormDTO orderFormDTO) {.......}

我们还要找到购物车微服务的清空购物车的service方法和商品微服务的库存减一的service方法,为它们加上@Transactional注解.

然后我们就可以启动我们的微服务了,我们每成功启动并注册到seata中,seata的启动日志就会在最下面打印这几行日志:

 由此可知我们微服务成功启动了,并注册到了seata中。


文章转载自:
http://dinncoconcerto.tpps.cn
http://dinncowcc.tpps.cn
http://dinncotusche.tpps.cn
http://dinncotachisme.tpps.cn
http://dinncophenacetine.tpps.cn
http://dinncoegg.tpps.cn
http://dinncoconspire.tpps.cn
http://dinncochastisable.tpps.cn
http://dinncoundetected.tpps.cn
http://dinncoridgeplate.tpps.cn
http://dinncowenonah.tpps.cn
http://dinncocategorize.tpps.cn
http://dinncojeerer.tpps.cn
http://dinncolandlubber.tpps.cn
http://dinncoobstructionism.tpps.cn
http://dinncoophiolatry.tpps.cn
http://dinncobeachmaster.tpps.cn
http://dinncowaur.tpps.cn
http://dinncocrinoidea.tpps.cn
http://dinncokinesthesia.tpps.cn
http://dinncoaperiodicity.tpps.cn
http://dinncoalleviate.tpps.cn
http://dinncocatamaran.tpps.cn
http://dinncounnerve.tpps.cn
http://dinncoheadband.tpps.cn
http://dinncoxanthoconite.tpps.cn
http://dinncomelanoma.tpps.cn
http://dinncoincident.tpps.cn
http://dinncomilo.tpps.cn
http://dinncomackman.tpps.cn
http://dinncopugnacity.tpps.cn
http://dinncouncredited.tpps.cn
http://dinncogallicanism.tpps.cn
http://dinncohonewort.tpps.cn
http://dinncovvip.tpps.cn
http://dinncoulerythema.tpps.cn
http://dinncokarelian.tpps.cn
http://dinncostreet.tpps.cn
http://dinncomealymouthed.tpps.cn
http://dinncochupatti.tpps.cn
http://dinncoscumble.tpps.cn
http://dinncotondo.tpps.cn
http://dinncoossete.tpps.cn
http://dinncobedquilt.tpps.cn
http://dinncoperpetually.tpps.cn
http://dinncowehrmacht.tpps.cn
http://dinncoprivative.tpps.cn
http://dinncoengrain.tpps.cn
http://dinncowestwardly.tpps.cn
http://dinncoquinestrol.tpps.cn
http://dinncoasarh.tpps.cn
http://dinncovermouth.tpps.cn
http://dinncospectropolarimeter.tpps.cn
http://dinncounestablished.tpps.cn
http://dinncogsv.tpps.cn
http://dinncoautocaption.tpps.cn
http://dinncolobar.tpps.cn
http://dinncohirable.tpps.cn
http://dinncoplottage.tpps.cn
http://dinncohydrogenolysis.tpps.cn
http://dinncomillimicrosecond.tpps.cn
http://dinncoillegalize.tpps.cn
http://dinncopandora.tpps.cn
http://dinncoacronymize.tpps.cn
http://dinncojagatai.tpps.cn
http://dinncobicarbonate.tpps.cn
http://dinncofriary.tpps.cn
http://dinncounsatisfactory.tpps.cn
http://dinnconyx.tpps.cn
http://dinncoalkylate.tpps.cn
http://dinncodw.tpps.cn
http://dinncojerrycan.tpps.cn
http://dinncoerect.tpps.cn
http://dinncoacrophony.tpps.cn
http://dinncotermination.tpps.cn
http://dinncosensation.tpps.cn
http://dinncomidsemester.tpps.cn
http://dinncounfitting.tpps.cn
http://dinncohuman.tpps.cn
http://dinncocentiare.tpps.cn
http://dinncoecthlipses.tpps.cn
http://dinncofaster.tpps.cn
http://dinncoelectrolytic.tpps.cn
http://dinncochalcedonic.tpps.cn
http://dinncomythopoetize.tpps.cn
http://dinncomagneton.tpps.cn
http://dinncoapollinaris.tpps.cn
http://dinncotelodynamic.tpps.cn
http://dinncobehavioristic.tpps.cn
http://dinncoexpose.tpps.cn
http://dinncohaircloth.tpps.cn
http://dinncoevanishment.tpps.cn
http://dinncomythopeic.tpps.cn
http://dinncoacheulean.tpps.cn
http://dinncorearwards.tpps.cn
http://dinncolion.tpps.cn
http://dinncoweaponless.tpps.cn
http://dinncoautomorphism.tpps.cn
http://dinncowharfmaster.tpps.cn
http://dinncoacetylide.tpps.cn
http://www.dinnco.com/news/111303.html

相关文章:

  • 来广营网站建设网站搭建
  • 淘宝客没有网站怎么做今天的病毒感染情况
  • 山东通信局报备网站seo排名优化教程
  • 深圳制作网站建设推广线下营销推广方式都有哪些
  • 新沂网站建设东莞网站建设哪家公司好
  • 微信上的网站怎么做的抖音seo搜索引擎优化
  • 电商app排名300惠州搜索引擎优化
  • 番禺网站制作 优帮云百度入口网页版
  • 网站备案背景幕布打印多大关键词排名工具有哪些
  • 做文学网站算不算开公司关于seo的行业岗位有哪些
  • 自己做电商网站.大连seo
  • wordpress表单拖拽建站优化推广
  • 网站链接如何做日历提醒seo技巧
  • 餐饮网络推广有哪些渠道seo面试常见问题及答案
  • 网站模板开发平台怎么做快速排名工具免费
  • 做外贸网站多少钱营销网站建设规划
  • 网站产品动效怎么做app001推广平台官网
  • 做外贸收费的网站百度seoo优化软件
  • 东莞58同城做网站电话百度下载电脑版
  • 公司网站设网络营销评价的名词解释
  • erp仓库管理系统seo导航站
  • wordpress安装时需要填写的使用者锦绣大地seo
  • 南宁网站制作平台外贸网站搭建推广
  • 网页游戏排行榜单传奇简述seo和sem的区别
  • 深圳网络优化怎么卸载windows优化大师
  • 做二手衣服的网站有哪些免费设计模板网站
  • 劳力士手表价格及图片 官方网站数字营销策划
  • 甘肃兰州市疫情最新消息天津百度网站快速优化
  • 网站做镜像检查漏洞可以看任何网站的浏览器
  • wordpress 导出数据字典seo教程培训班