Giter VIP home page Giter VIP logo

myth's Introduction

myth

Codacy Badge Total lines License Maven Central QQ群

Reliable messages resolve distributed transactions

Modules

  • myth-admin: Transaction log management background

  • myth-annotation : Framework common annotations

  • myth-common : Framework common class

  • myth-core : Framework core package (annotation processing, log storage...)

  • myth-dashboard : Management background front-end

  • myth-dubbo : Support for the dubbo framework Less than 2.7 version

  • myth-motan : Support for the motan rpc framework

  • myth-springcloud : Support for the spring cloud rpc framework

  • myth-spring-boot-starter : Support for the spring boot starter

  • myth-aliyunmq: Support for aliyunmq

  • myth-jms : support for Mq for the JMS protocol(amq...)

  • myth-kafka : support for kafka

  • myth-rabbitmq : support for rabbitmq

  • myth-rocketmq : support for rocketmq

  • hmily-demo : Examples using the hmily framework

Features

  • All spring versions are supported and Seamless integration

  • Provides support for the springcloud dubbo motan RPC framework

  • Provides integration of the spring boot starter approach

  • Support for a lot of messaging middleware (rabbitmq jms kafka rabbitmq rocketmq)

  • Local transaction storage support : redis mongodb zookeeper file mysql

  • Transaction log serialization support : java hessian kryo protostuff

  • Spi extension : Users can customize the storage of serialization and transaction logs

Prerequisite

  • You must use jdk1.8 +

  • You must be a user of the spring framework

  • You must use messaging middleware

  • You must use one of the dubbo, motan, and springcloud RPC frameworks

About

Myth is a Reliable messages solution for distributed transactions, Its rapid integration, zero penetration high performance has been run by a number of companies in the production environment.

Myth is not a framework for exception rollbacks .

Myth To ensure that your RPC interface can be executed, use mq to execute the RPC you need to call when your RPC interface is down

If you want to use it or get a quick look at it. Quick Start

Quick Start

  • Clone & Build

> git clone https://github.com/yu199195/myth.git

> cd myth

> mvn -DskipTests clean install -U

Stargazers

Stargazers over time

Support

myth's People

Contributors

411241940 avatar bing-ok avatar codacy-badger avatar dependabot[bot] avatar itonyli avatar lnnlab avatar xqxyxchy avatar yu199195 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

myth's Issues

这个项目在一些极端情况下考虑的

如最后一个用户购买成功后,启用订单系统,在调关闭产品系统的优惠功能,然后再调积分系统,最后调仓库系统减商品数量。如果订单系统在掉积分系统成功后,断电了?消息事物还成立吗?

接收mq消息重试时,SpringCloudMythTransactionInterceptor 拦截器 异常

mq消息监听时,重试方法时,会进入到AOP切面获取request;但实际上这个不是Feign调用,
无法获取request;
异常代码:
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
异常
java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

并发测试下的问题

作者您好!
附件的图片是我并发测试的结果,2个线程就出现数据不一致了。
是我测试方式不对还是程序存在并发问题?
跑的是dmeo

default
default
default
default
default

事务不理想,不能全部回滚

我修改了一下业务代码,把我的钱变成0,特地让程序报异常,钱不是扣了,但是订单和库存还是扣了,myth可能做到全部回滚不?我看了其他人的问题,这个程序不管怎么搞,订单还是会生成的。最后还是想问问能不能一次性回滚,像lcn那样。

如果消息压根就没有发出去怎么保证一致性

代码里面保证一致性最重要的一环就是基于finally去sendmsg保证异常的时候能够把消息发到消息队列,从而保证最终一致性,有几种异常情况处理不了,列举一种:本地操作了数据库之后(orderPay的orderMapper.save刚好执行完成),本地程序挂了。。这时候因为在orderservice上面没有本地事务,order保存是成功的,但是消息队列里面没有消息,账号和库存服务都拿不到相应要执行的东西,事务不一致了

zookeeper方式存储事务日志报错

2018-08-22 16:37:57.126 ERROR 10168 --- [ruptor-thread-1] .g.m.c.d.p.MythTransactionEventPublisher : Disruptor handleEventException:2MythTransaction(transId=891075360, status=1, role=3, retriedCount=0, createTime=Wed Aug 22 16:36:22 CST 2018, lastTime=Wed Aug 22 16:36:22 CST 2018, version=1, targetClass=com.github.myth.demo.springcloud.account.service.impl.AccountServiceImpl, targetMethod=payment, errorMsg=null, mythParticipants=[])org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists for /myth-account-service/891075360

demo-springcloud 缺少http-core jar

直接从git拉取下来的master分支,运行eureka
抛错:Caused by: java.lang.ClassNotFoundException: org.apache.http.util.Args

需添加
http-core jar eureka才能运行

阿里云MQ的实现

感谢作者大大,提供了分布式事务的实现方案,让我可以作为学习和参考的基础.

通过对框架的理解,个人实现了阿里云MQ的方式.
不知道是否可以提交到一个分支.

不能保证分布式事物

不能保证分布式事物,我在order服务方法最后一行抛了一个异常,但我余额和库存都扣减了

spring cloud kafka一直扣用户余额

我先在acount的service抛出一个异常,然后执行order,去掉抛出异常的代码,让其能够正常执行,重启acount的服务,结果用户余额一直被扣

关于事务落库后,业务操作失败的情况怎么处理?

项目中有四个库
事务日志库,对应着有
message_account_service(账户事务日志表)
message_order_service(订单事务日志表)
message_inventory_service(库存事务日志表)
订单库:有表 order
账户库: 有表 account
库存库:有表 inventory

现有以下几个情况:
1、下单时,扣减账户和扣减库存都是成功的;但在订单服务的最后可能发生了异常,此时账户和订单的事务日志表记得的状态都是成功的,订单事务日志表的状态是失败;此时要怎么处理?(重试的方式执行下单操作吗,可现在的表里没有记录下单时的参数信息)

2、下单时,扣减账户失败,扣减库存成功;此时账户的事务日志表状态是失败,订单和库存的事务日志表状态是成功;此时要怎么处理?

“NoSuchMethodErrors” due to multiple versions of org.slf4j:slf4j-api:jar

Hi, there are multiple versions of org.slf4j:slf4j-api in myth-master\myth-rpc\myth-motan. As shown in the following dependency tree, according to Maven's “nearest wins” strategy, only org.slf4j:slf4j-api:1.7.25 can be loaded, and org.slf4j:slf4j-api:1.5.8 will be shadowed.

As org.slf4j:slf4j-api:1.5.8 has not been loaded during the building process, several methods are missing. However, the missing methods:
1. org.slf4j.helpers.MessageFormatter: java.lang.String format(java.lang.String,java.lang.Object)

Check for details of invocation
paths------
<org.dromara.myth.motan.interceptor.MotanMythTransactionInterceptor: java.lang.Object interceptor(org.aspectj.lang.ProceedingJoinPoint)> myth-master\myth-rpc\myth-motan\target\classes
<org.dromara.myth.core.service.impl.MythTransactionAspectServiceImpl: java.lang.Object invoke(org.dromara.myth.common.bean.context.MythTransactionContext,org.aspectj.lang.ProceedingJoinPoint)> Repositories\org\dromara\myth-core\2.0.2-RELEASE\myth-core-2.0.2-RELEASE.jar
<org.dromara.myth.core.service.handler.ActorMythTransactionHandler: java.lang.Object handler(org.aspectj.lang.ProceedingJoinPoint,org.dromara.myth.common.bean.context.MythTransactionContext)> Repositories\org\dromara\myth-core\2.0.2-RELEASE\myth-core-2.0.2-RELEASE.jar
<org.dromara.myth.common.utils.LogUtil: void error(org.slf4j.Logger,java.lang.String,java.util.function.Supplier)> Repositories\org\dromara\myth-common\2.0.2-RELEASE\myth-common-2.0.2-RELEASE.jar
<org.slf4j.impl.Log4jLoggerAdapter: void error(java.lang.String,java.lang.Object)> Repositories\org\slf4j\slf4j-log4j12\1.7.25\slf4j-log4j12-1.7.25.jar
<org.slf4j.helpers.MessageFormatter: java.lang.String format(java.lang.String,java.lang.Object)>

The above missing methods are actually referenced by myth-master\myth-rpc\myth-motan, which will cause “NoSuchMethodErrors” at runtime.

Suggested fixing solutions:

  1. Upgrading dependency com.weibo:motan-core, com.weibo:motan-springsupport and com.weibo:motan-transport-netty from 1.0.0 to 1.1.2 can solve this dependency conflict.
  2. Change dependency org.slf4j:slf4j-api from 1.7.25 to 1.5.8.
  3. Use configuration attribute <dependencyManagement> to unify the version of library org.slf4j:slf4j-api to be 1.5.8 in myth-master\myth-rpc\myth-motan's pom file.

Please let me know which solution do you prefer? I can submit a PR to fix it.

Thank you very much for your attention.
Best regards,

Dependency tree----

click for details
[INFO] org.dromara:myth-motan:jar:2.0.2-RELEASE
[INFO] +- org.dromara:myth-core:jar:2.0.2-RELEASE:compile
[INFO] | +- org.dromara:myth-common:jar:2.0.2-RELEASE:compile
[INFO] | | +- (org.dromara:myth-annotation:jar:2.0.2-RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.apache.commons:commons-lang3:jar:3.3.2:compile - omitted for duplicate)
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | | +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | | +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | +- (ch.qos.logback:logback-core:jar:1.2.3:compile - omitted for duplicate)
[INFO] | | | \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
[INFO] | | +- com.google.code.gson:gson:jar:2.6.2:compile
[INFO] | | +- com.squareup.okhttp3:okhttp:jar:3.7.0:compile
[INFO] | | | \- com.squareup.okio:okio:jar:1.12.0:compile
[INFO] | | +- com.google.guava:guava:jar:21.0:compile
[INFO] | | +- redis.clients:jedis:jar:2.9.0:compile
[INFO] | | | \- org.apache.commons:commons-pool2:jar:2.6.0:compile (version managed from 2.4.2)
[INFO] | | +- org.projectlombok:lombok:jar:1.16.20:compile
[INFO] | | +- com.esotericsoftware:kryo-shaded:jar:4.0.0:compile
[INFO] | | | +- com.esotericsoftware:minlog:jar:1.3.0:compile
[INFO] | | | \- org.objenesis:objenesis:jar:2.2:compile
[INFO] | | +- com.dyuproject.protostuff:protostuff-core:jar:1.0.8:compile
[INFO] | | | \- com.dyuproject.protostuff:protostuff-api:jar:1.0.8:compile
[INFO] | | +- com.dyuproject.protostuff:protostuff-runtime:jar:1.0.8:compile
[INFO] | | | +- (com.dyuproject.protostuff:protostuff-api:jar:1.0.8:compile - omitted for duplicate)
[INFO] | | | \- com.dyuproject.protostuff:protostuff-collectionschema:jar:1.0.8:compile
[INFO] | | | \- (com.dyuproject.protostuff:protostuff-api:jar:1.0.8:compile - omitted for duplicate)
[INFO] | | +- com.caucho:hessian:jar:4.0.38:compile
[INFO] | | \- org.mongodb:mongo-java-driver:jar:3.5.0:compile
[INFO] | +- org.dromara:myth-annotation:jar:2.0.2-RELEASE:compile
[INFO] | +- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] | +- com.lmax:disruptor:jar:3.4.0:compile
[INFO] | \- org.apache.zookeeper:zookeeper:jar:3.4.9:compile
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.6.1; omitted for duplicate)
[INFO] | +- log4j:log4j:jar:1.2.14:compile
[INFO] | +- jline:jline:jar:0.9.94:compile
[INFO] | \- io.netty:netty:jar:3.10.5.Final:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] +- org.springframework:spring-context:jar:5.1.3.RELEASE:provided
[INFO] | +- org.springframework:spring-aop:jar:5.1.3.RELEASE:provided
[INFO] | | +- (org.springframework:spring-beans:jar:5.1.3.RELEASE:provided - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-core:jar:5.1.3.RELEASE:provided - omitted for duplicate)
[INFO] | +- org.springframework:spring-beans:jar:5.1.3.RELEASE:provided
[INFO] | | \- (org.springframework:spring-core:jar:5.1.3.RELEASE:provided - omitted for duplicate)
[INFO] | +- org.springframework:spring-core:jar:5.1.3.RELEASE:provided
[INFO] | | \- org.springframework:spring-jcl:jar:5.1.3.RELEASE:provided
[INFO] | \- org.springframework:spring-expression:jar:5.1.3.RELEASE:provided
[INFO] | \- (org.springframework:spring-core:jar:5.1.3.RELEASE:provided - omitted for duplicate)
[INFO] +- com.weibo:motan-core:jar:1.0.0:provided
[INFO] | +- commons-pool:commons-pool:jar:1.6:provided
[INFO] | +- (com.caucho:hessian:jar:4.0.38:compile - scope updated from provided; omitted for duplicate)
[INFO] | +- com.alibaba:fastjson:jar:1.1.30:provided
[INFO] | +- com.codahale.metrics:metrics-core:jar:3.0.1:provided
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.25:provided - version managed from 1.7.5; omitted for duplicate)
[INFO] | +- (com.google.guava:guava:jar:21.0:compile - version managed from 18.0; scope updated from provided; omitted for duplicate)
[INFO] | +- com.squareup:javapoet:jar:1.8.0:provided
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.5.8; scope updated from provided; omitted for duplicate)
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.25:provided (version managed from 1.5.8)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.25:provided - version managed from 1.5.8; omitted for duplicate)
[INFO] | | \- (log4j:log4j:jar:1.2.17:provided - omitted for conflict with 1.2.14)
[INFO] | +- (log4j:log4j:jar:1.2.14:compile - scope updated from provided; omitted for duplicate)
[INFO] | +- (org.apache.commons:commons-lang3:jar:3.3.2:provided - version managed from 3.1; omitted for duplicate)
[INFO] | \- commons-codec:commons-codec:jar:1.11:provided (version managed from 1.4)
[INFO] +- com.weibo:motan-springsupport:jar:1.0.0:provided
[INFO] | +- (com.weibo:motan-core:jar:1.0.0:provided - omitted for duplicate)
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.5.8; scope updated from provided; omitted for duplicate)
[INFO] | +- (org.slf4j:slf4j-log4j12:jar:1.7.25:provided - version managed from 1.5.8; omitted for duplicate)
[INFO] | +- (log4j:log4j:jar:1.2.14:compile - scope updated from provided; omitted for duplicate)
[INFO] | +- (org.apache.commons:commons-lang3:jar:3.3.2:provided - version managed from 3.1; omitted for duplicate)
[INFO] | \- (commons-codec:commons-codec:jar:1.11:provided - version managed from 1.4; omitted for duplicate)
[INFO] \- com.weibo:motan-transport-netty:jar:1.0.0:provided
[INFO] +- org.jboss.netty:netty:jar:3.2.5.Final:provided
[INFO] +- (com.weibo:motan-core:jar:1.0.0:provided - omitted for duplicate)
[INFO] +- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.5.8; scope updated from provided; omitted for duplicate)
[INFO] +- (org.slf4j:slf4j-log4j12:jar:1.7.25:provided - version managed from 1.5.8; omitted for duplicate)
[INFO] +- (log4j:log4j:jar:1.2.14:compile - scope updated from provided; omitted for duplicate)
[INFO] +- (org.apache.commons:commons-lang3:jar:3.3.2:provided - version managed from 3.1; omitted for duplicate)
[INFO] \- (commons-codec:commons-codec:jar:1.11:provided - version managed from 1.4; omitted for duplicate)

事务发起方发生系统级别异常导致本地事务回滚远程事务成功,但是本地事务日志已经变成commit状态

1、业务中调用远程事务时,远程事务成功了;
myth-01
2、远程服务返回时feign在解码时报错了,导致发起方事务回滚;
3、发起方最终还是会发送消息到远程服务,并且成功后本地事务日志会变成commit状态,可是第2步本地事务回滚了;
myth-02
4、最终导致数据不一致,事务日志也变成commit了,无法再进行补偿;

总结:上述问题该怎么处理;

新建项目 恢复服务报错 No qualifying bean of type 'xxx.xxx' available

现有两种情况可供作者分析
第一种:myth框架的demo正常,可恢复。 在我原来的项目中(非myth目录),添加myth框架支持。
尝试启动eureka,myth-demo-springcloud-account,myth-demo-springcloud-inventory, 我自己的项目(做为消费者远程调用account,inventory服务),一切正常,包括停掉account或者inventory服务,重启恢复也正常
第二种:将account服务复制拷贝一份到我的项目下,目前只修改了pom文件的parent,正常流程是通的,消息恢复服务 依然不通,account复制服务消费消息恢复时 依旧报错No qualifying bean of type 'xxx.xxx' available
希望作者早点看到,我在QQ群里

关于分布式事务回滚的疑问

以 demo中的 myth-demo-spring-cloud-inventory 为例,

order 模块的 PaymentServiceImpl.makePayment 先询问了 account 模块的余额 和 inventory 模块的 库存, 假设目前 余额和库存 都足够, 然后 发起了 accountClient.payment 和 inventoryClient.decrease

这时 accountClient.payment 正常执行了。
而 inventoryClient.decrease 由于 并发的存在, 可能这时 库存已经被别人的订单 减为 0, 从而 这次的 inventoryClient.decrease 抛出了 MythRuntimeException("spring cloud inventory-service 库存不足!")

那这种情况下, account 模块 应该不会被回滚吧? 是不是 只能用tcc 方法来解决这些问题, 可靠消息 只能 保证 减库存操作一定被发送到, 但能不能扣减成功就没办法了?

springcluod 的demo里的两个-api

能不要吗,感觉不太适用 在 springcloud 框架中,比如,account服务,account-api就 应该只能account服务用,别的服务不能用

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.