├── easytrans-core ├── readme.md ├── src │ └── main │ │ └── java │ │ └── com │ │ └── yiqiniu │ │ └── easytrans │ │ ├── protocol │ │ ├── SerializableVoid.java │ │ ├── RpcBusinessProvider.java │ │ ├── RequestClassAware.java │ │ ├── saga │ │ │ ├── AbstractSagaTccMethodRequest.java │ │ │ └── SagaTccMethodRequest.java │ │ ├── msg │ │ │ ├── ReliableMessageHandler.java │ │ │ ├── BestEffortMessageHandler.java │ │ │ ├── AbstractReliableMessagePublishRequest.java │ │ │ ├── AbstractBestEffortMessagePublishRequest.java │ │ │ ├── ReliableMessagePublishRequest.java │ │ │ ├── BestEffortMessagePublishRequest.java │ │ │ ├── PublishResult.java │ │ │ ├── EtReliableMsg.java │ │ │ └── EtBestEffortMsg.java │ │ ├── tcc │ │ │ ├── AbstractTccMethodRequest.java │ │ │ ├── TccMethodRequest.java │ │ │ └── EtTcc.java │ │ ├── autocps │ │ │ ├── AbstractAutoCpsMethodRequest.java │ │ │ ├── AutoCpsMethodRequest.java │ │ │ ├── AutoCpsLocalTransactionExecutor.java │ │ │ └── EtAutoCps.java │ │ ├── cps │ │ │ ├── AbstractCompensableMethodRequest.java │ │ │ ├── CompensableMethodRequest.java │ │ │ └── EtCps.java │ │ ├── EasyTransRequest.java │ │ ├── aft │ │ │ ├── AbstractAfterMasterTransRequest.java │ │ │ ├── AfterMasterTransRequest.java │ │ │ ├── AfterMasterTransMethod.java │ │ │ └── EtAfterMasterTrans.java │ │ ├── AbstractEasyTransRequest.java │ │ ├── MessageBusinessProvider.java │ │ ├── MethodTransactionStatus.java │ │ ├── BusinessIdentifer.java │ │ ├── BusinessProvider.java │ │ └── ExecuteOrder.java │ │ ├── idgen │ │ ├── TrxIdGenerator.java │ │ ├── BusinessCodeGenerator.java │ │ └── impl │ │ │ └── ConstantBusinessCodeGenerator.java │ │ ├── serialization │ │ ├── ObjectSerializer.java │ │ └── impl │ │ │ └── SpringObjectSerialization.java │ │ ├── idempotent │ │ ├── IdempotentHandlerFilter.java │ │ ├── exception │ │ │ └── ResultWrapperExeception.java │ │ ├── IdempotentTransactionDefinition.java │ │ └── DefaultIdempotentTransactionDefinition.java │ │ ├── monitor │ │ ├── StringCodecMonitor.java │ │ ├── EtMonitor.java │ │ ├── TransactionLogMonitor.java │ │ ├── MonitorConsumerFactory.java │ │ └── server │ │ │ └── ServerSideStringCodecMonitor.java │ │ ├── stringcodec │ │ ├── ListableStringCodec.java │ │ ├── impl │ │ │ ├── EnableStringCodecZookeeperImpl.java │ │ │ ├── ZookeeperStringCodecProperties.java │ │ │ └── ZookeeperStringCodecConfiguration.java │ │ └── StringCodec.java │ │ ├── queue │ │ ├── consumer │ │ │ ├── EasyTransMsgListener.java │ │ │ ├── EasyTransConsumeAction.java │ │ │ └── EasyTransMsgConsumer.java │ │ ├── IdenticalQueueTopicMapper.java │ │ ├── producer │ │ │ ├── EasyTransMsgPublisher.java │ │ │ └── EasyTransMsgPublishResult.java │ │ └── QueueTopicMapper.java │ │ ├── util │ │ ├── ByteFormIdCodec.java │ │ └── FutureAdapter.java │ │ ├── context │ │ ├── event │ │ │ ├── GuardianProcessEndEventHandler.java │ │ │ └── DemiLogEventHandler.java │ │ └── MasterTransactionStatusVotter.java │ │ ├── log │ │ ├── vo │ │ │ ├── trx │ │ │ │ ├── TransactionFinishedContent.java │ │ │ │ └── TransactionBeginContent.java │ │ │ ├── AfterCommit.java │ │ │ ├── AfterRollBack.java │ │ │ ├── aft │ │ │ │ ├── AfterTransCalledContent.java │ │ │ │ └── AfterTransCallRegisterContent.java │ │ │ ├── tcc │ │ │ │ ├── TccCallConfirmedContent.java │ │ │ │ ├── TccCallCancelledContent.java │ │ │ │ └── PreTccCallContent.java │ │ │ ├── compensable │ │ │ │ ├── CompensatedContent.java │ │ │ │ └── PreCompensableCallContent.java │ │ │ ├── fescar │ │ │ │ ├── FescarAtCallCommitedContent.java │ │ │ │ ├── FescarAtCallRollbackedContent.java │ │ │ │ └── FescarAtPreCallContent.java │ │ │ ├── saga │ │ │ │ ├── SagaTccCallConfirmedContent.java │ │ │ │ ├── SagaTccCallCancelledContent.java │ │ │ │ └── PreSagaTccCallContent.java │ │ │ ├── DemiLeftContent.java │ │ │ ├── DemiRightContent.java │ │ │ └── msg │ │ │ │ ├── MessageRecordContent.java │ │ │ │ └── MessageSentContent.java │ │ ├── TransactionLogWritter.java │ │ └── TransactionLogReader.java │ │ ├── executor │ │ ├── RelativeInterface.java │ │ └── EasyTransExecutor.java │ │ ├── core │ │ ├── EasyTransFacade.java │ │ ├── LogProcessor.java │ │ └── EasytransConstant.java │ │ ├── provider │ │ └── factory │ │ │ └── ListableProviderFactory.java │ │ ├── rpc │ │ ├── EasyTransRpcConsumer.java │ │ └── EasyTransRpcProvider.java │ │ ├── master │ │ ├── impl │ │ │ ├── EnableMasterZookeeperImpl.java │ │ │ ├── ZookeeperMasterSelectorProperties.java │ │ │ └── ZookeeperMasterSelectorConfiguration.java │ │ └── EasyTransMasterSelector.java │ │ └── filter │ │ ├── EasyTransFilter.java │ │ ├── EasyTransFilterChainFactory.java │ │ └── EasyTransFilterChain.java └── .gitignore ├── easytrans-queue-ons-starter ├── readme.md ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── queue │ │ │ └── impl │ │ │ └── ons │ │ │ └── EnableQueueOnsImpl.java │ └── test │ │ └── resources │ │ └── log4j.properties └── pom.xml ├── easytrans-rpc-dubbo-starter ├── readme.md ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── dubbo │ │ │ └── com.alibaba.dubbo.rpc.Filter │ │ └── java │ │ └── com │ │ └── yiqiniu │ │ └── easytrans │ │ └── rpc │ │ └── impl │ │ └── dubbo │ │ ├── DubboReferanceCustomizationer.java │ │ ├── DubboServiceCustomizationer.java │ │ ├── DubboEasyTransRpcProperties.java │ │ └── EnableRpcDubboImpl.java └── .gitignore ├── easytrans-queue-kafka-starter ├── readme.md ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── yiqiniu │ │ └── easytrans │ │ └── queue │ │ └── impl │ │ └── kafka │ │ ├── EnableQueueKafkaImpl.java │ │ └── QueueKafkaHelper.java └── pom.xml ├── easytrans-log-redis-starter ├── readme.md ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── yiqiniu │ │ └── easytrans │ │ └── log │ │ └── impl │ │ └── redis │ │ ├── EnableLogRedisImpl.java │ │ └── RedisTransactionLogProperties.java └── pom.xml ├── easytrans-demo ├── interface-call-nozk │ ├── readme.md │ ├── .gitignore │ ├── interfacecallnozk-order-service │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── order │ │ │ │ └── impl │ │ │ │ ├── Constant.java │ │ │ │ └── OrderController.java │ │ └── .gitignore │ ├── interfacecallnozk-wallet-api │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── wallet │ │ │ └── api │ │ │ ├── WalletServiceApiConstant.java │ │ │ └── requestcfg │ │ │ └── WalletPayRequestCfg.java │ └── interfacecallnozk-wallet-service │ │ ├── .gitignore │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── yiqiniu │ │ └── easytrans │ │ └── demos │ │ └── wallet │ │ └── impl │ │ └── WalletApplication.java ├── sagatcc │ ├── .gitignore │ ├── sagatcc-order-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── yiqiniu │ │ │ │ │ └── easytrans │ │ │ │ │ └── demos │ │ │ │ │ └── order │ │ │ │ │ └── impl │ │ │ │ │ ├── Constant.java │ │ │ │ │ ├── OrderApplication.java │ │ │ │ │ └── OrderController.java │ │ │ │ └── resources │ │ │ │ ├── application.yml │ │ │ │ └── log4j.properties │ │ └── .gitignore │ ├── sagatcc-wallet-api │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── api │ │ │ │ ├── WalletServiceApiConstant.java │ │ │ │ └── vo │ │ │ │ └── WalletPayVO.java │ │ └── pom.xml │ └── sagatcc-wallet-service │ │ ├── .gitignore │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── wallet │ │ │ └── impl │ │ │ ├── WalletApplication.java │ │ │ └── WalletPaySagaTccService.java │ │ └── resources │ │ ├── application.yml │ │ └── log4j.properties ├── tcc-only │ ├── .gitignore │ ├── tcconly-order-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── yiqiniu │ │ │ │ │ └── easytrans │ │ │ │ │ └── demos │ │ │ │ │ └── order │ │ │ │ │ └── impl │ │ │ │ │ ├── Constant.java │ │ │ │ │ ├── OrderApplication.java │ │ │ │ │ └── OrderController.java │ │ │ │ └── resources │ │ │ │ └── application.yml │ │ └── .gitignore │ ├── tcconly-wallet-api │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── api │ │ │ │ └── WalletServiceApiConstant.java │ │ └── pom.xml │ ├── tcconly-wallet-service │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── impl │ │ │ │ ├── WalletApplication.java │ │ │ │ └── WalletPayTccService.java │ │ │ └── resources │ │ │ └── application.yml │ └── readme.md ├── log-redis │ ├── .gitignore │ ├── logredis-order-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── yiqiniu │ │ │ │ │ └── easytrans │ │ │ │ │ └── demos │ │ │ │ │ └── order │ │ │ │ │ └── impl │ │ │ │ │ ├── Constant.java │ │ │ │ │ ├── OrderApplication.java │ │ │ │ │ └── OrderController.java │ │ │ │ └── resources │ │ │ │ ├── application.yml │ │ │ │ └── log4j.properties │ │ └── .gitignore │ ├── logredis-wallet-api │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── api │ │ │ │ └── WalletServiceApiConstant.java │ │ └── pom.xml │ ├── logredis-wallet-service │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── impl │ │ │ │ ├── WalletApplication.java │ │ │ │ └── WalletPayTccService.java │ │ │ └── resources │ │ │ └── application.yml │ └── readme.md ├── rpc-dubbo │ ├── .gitignore │ ├── rpcdubbo-order-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── yiqiniu │ │ │ │ │ └── easytrans │ │ │ │ │ └── demos │ │ │ │ │ └── order │ │ │ │ │ └── impl │ │ │ │ │ ├── Constant.java │ │ │ │ │ └── OrderController.java │ │ │ │ └── resources │ │ │ │ └── log4j.properties │ │ └── .gitignore │ ├── rpcdubbo-wallet-api │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── api │ │ │ │ └── WalletServiceApiConstant.java │ │ └── pom.xml │ ├── rpcdubbo-wallet-service │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── wallet │ │ │ └── impl │ │ │ └── WalletPayTccService.java │ └── readme.md ├── tcc-and-msg │ ├── .gitignore │ ├── tccandmsg-order-api │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── order │ │ │ │ └── api │ │ │ │ ├── OrderServiceApiConstant.java │ │ │ │ └── vo │ │ │ │ └── OrderFinishedMessage.java │ │ └── pom.xml │ ├── tccandmsg-wallet-api │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── api │ │ │ │ └── WalletServiceApiConstant.java │ │ └── pom.xml │ ├── tccandmsg-point-service │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── point │ │ │ └── impl │ │ │ ├── PointApplication.java │ │ │ ├── PointService.java │ │ │ └── OrderFinishedMessageHandler.java │ ├── tccandmsg-wallet-service │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── impl │ │ │ │ ├── WalletApplication.java │ │ │ │ └── WalletPayTccService.java │ │ │ └── resources │ │ │ └── application.yml │ ├── tccandmsg-order-service │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── order │ │ │ └── impl │ │ │ ├── OrderApplication.java │ │ │ └── OrderController.java │ └── readme.md ├── interface-call │ ├── .gitignore │ ├── interfacecall-order-service │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── yiqiniu │ │ │ │ │ └── easytrans │ │ │ │ │ └── demos │ │ │ │ │ └── order │ │ │ │ │ └── impl │ │ │ │ │ ├── Constant.java │ │ │ │ │ ├── OrderController.java │ │ │ │ │ └── OrderApplication.java │ │ │ │ └── resources │ │ │ │ └── application.yml │ │ └── .gitignore │ ├── interfacecall-wallet-api │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── api │ │ │ │ ├── WalletServiceApiConstant.java │ │ │ │ └── requestcfg │ │ │ │ └── WalletPayRequestCfg.java │ │ └── pom.xml │ ├── interfacecall-wallet-service │ │ ├── .gitignore │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── yiqiniu │ │ │ │ └── easytrans │ │ │ │ └── demos │ │ │ │ └── wallet │ │ │ │ └── impl │ │ │ │ └── WalletApplication.java │ │ │ └── resources │ │ │ └── application.yml │ └── readme.md └── tcc-and-fescar │ ├── .gitignore │ ├── tccandfescar-coupon-api │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── wallet │ │ │ └── api │ │ │ └── CouponServiceApiConstant.java │ └── pom.xml │ ├── tccandfescar-order-service │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── order │ │ │ └── impl │ │ │ ├── Constant.java │ │ │ ├── OrderApplication.java │ │ │ └── OrderController.java │ └── .gitignore │ ├── tccandfescar-wallet-api │ ├── .gitignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── wallet │ │ │ └── api │ │ │ └── WalletServiceApiConstant.java │ └── pom.xml │ ├── tccandfescar-wallet-service │ ├── .gitignore │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── wallet │ │ │ └── impl │ │ │ ├── WalletApplication.java │ │ │ └── WalletPayTccService.java │ │ └── resources │ │ └── application.yml │ ├── tccandfescar-coupon-service │ ├── .gitignore │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── wallet │ │ │ └── impl │ │ │ ├── CouponController.java │ │ │ ├── UseCouponAutoCpsService.java │ │ │ └── CouponApplication.java │ │ └── resources │ │ └── application.yml │ └── readme.md ├── easytrans-log-database-starter ├── readme.md ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── yiqiniu │ │ └── easytrans │ │ └── log │ │ └── impl │ │ └── database │ │ ├── EnableLogDatabaseImpl.java │ │ └── DataBaseTransactionLogDetail.java └── pom.xml ├── easytrans-dashboard ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── demos │ │ │ └── order │ │ │ └── impl │ │ │ └── Constant.java │ │ └── resources │ │ ├── templates │ │ ├── index.html │ │ └── string2IdMap.html │ │ ├── application.yml │ │ └── log4j.properties ├── .gitignore └── readme.md ├── easytrans-starter ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── spring.factories │ │ └── java │ │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ ├── EasyTransactionTrrigerConfiguration.java │ │ │ └── EnableEasyTransaction.java │ └── test │ │ ├── java │ │ └── com │ │ │ └── yiqiniu │ │ │ └── easytrans │ │ │ └── test │ │ │ ├── Constant.java │ │ │ └── mockservice │ │ │ ├── accounting │ │ │ └── easytrans │ │ │ │ └── AccountingApi.java │ │ │ ├── notification │ │ │ ├── NotificationService.java │ │ │ └── easytrans │ │ │ │ └── NotificationConsumer.java │ │ │ ├── order │ │ │ ├── OrderMessage.java │ │ │ ├── NotReliableOrderMessage.java │ │ │ └── OrderMessageForCascadingTest.java │ │ │ └── point │ │ │ └── easytrans │ │ │ ├── PointOrderSuccessConsumer.java │ │ │ └── PointOrderSuccessForCascadeTestConsumer.java │ │ └── resources │ │ └── log4j.properties └── readme.md ├── easytrans-rpc-rest-ribbon-starter ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── yiqiniu │ │ └── easytrans │ │ └── rpc │ │ └── impl │ │ └── rest │ │ ├── RestRibbonEasyTransConstants.java │ │ └── EnableRpcRestRibbonImpl.java └── pom.xml ├── easytrans-extensionsuite-database-starter ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── yiqiniu │ │ └── easytrans │ │ └── extensionsuite │ │ └── impl │ │ └── database │ │ ├── GetExtentionSuiteDatabase.java │ │ ├── EnableExtensionSuiteDatabaseImpl.java │ │ ├── DatabaseSnowFlakeIdGenerator.java │ │ └── DefaultGetExtensionSuiteDatasource.java └── readme.md ├── .gitignore └── .github └── ISSUE_TEMPLATE └── bug_report.md /easytrans-core/readme.md: -------------------------------------------------------------------------------- 1 | ## core implement -------------------------------------------------------------------------------- /easytrans-queue-ons-starter/readme.md: -------------------------------------------------------------------------------- 1 | ## QUEUE-ONS implement -------------------------------------------------------------------------------- /easytrans-rpc-dubbo-starter/readme.md: -------------------------------------------------------------------------------- 1 | ## RPC DUBBO implement -------------------------------------------------------------------------------- /easytrans-queue-kafka-starter/readme.md: -------------------------------------------------------------------------------- 1 | ## QUEUE-KAFKA implement 2 | -------------------------------------------------------------------------------- /easytrans-log-redis-starter/readme.md: -------------------------------------------------------------------------------- 1 | ## distrubuted transaction log redis implement -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/readme.md: -------------------------------------------------------------------------------- 1 | ## no zk 2 | 本DEMO演示了去掉ZK的配置,使用基于MYSQL的 3 | * 选主 4 | * ID生成 5 | * 字符串编码 6 | * 事务日志 -------------------------------------------------------------------------------- /easytrans-log-database-starter/readme.md: -------------------------------------------------------------------------------- 1 | ## distruibute transaction log relation database implement 2 | 3 | 可以自行替换DataBaseForLog的实例,选择自己使用的数据源 4 | 5 | -------------------------------------------------------------------------------- /easytrans-rpc-dubbo-starter/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter: -------------------------------------------------------------------------------- 1 | easyTransFilter=com.yiqiniu.easytrans.rpc.impl.dubbo.DubboEasyTransFilter -------------------------------------------------------------------------------- /easytrans-dashboard/src/main/java/com/yiqiniu/easytrans/demos/order/impl/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | public class Constant { 4 | } 5 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/SerializableVoid.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | public enum SerializableVoid { 4 | SINGLETON 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-core/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-starter/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Auto Configure 2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | com.yiqiniu.easytrans.EasyTransCoreConfiguration 4 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/idgen/TrxIdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.idgen; 2 | 3 | public interface TrxIdGenerator { 4 | long getCurrentTrxId(String busCode); 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/idgen/BusinessCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.idgen; 2 | 3 | public interface BusinessCodeGenerator { 4 | String getCurrentBusinessCode(); 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-log-redis-starter/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-queue-ons-starter/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-rpc-dubbo-starter/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.test; 2 | 3 | public class Constant { 4 | public static final String APPID="trx-test-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-log-database-starter/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-queue-kafka-starter/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-rpc-rest-ribbon-starter/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-extensionsuite-database-starter/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | /target/* 6 | /.settings/* 7 | /bin/* 8 | /.project 9 | /.classpath 10 | /logs 11 | /target/ 12 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/RpcBusinessProvider.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | public interface RpcBusinessProvider

> extends BusinessProvider

{ 4 | } 5 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .flattened-pom.xml 15 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-dashboard/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-demo/interface-call/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | public class Constant { 4 | public static final String APPID="order-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | public class Constant { 4 | public static final String APPID="order-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-starter/readme.md: -------------------------------------------------------------------------------- 1 | ## Easytrans-starter 2 | Sping Boot style configuration project,you just need to import this project in pom, add some config in application.yml, add @EnableEasyTransaction annotation and then you are able to use Easytransaction 3 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | public class Constant { 4 | public static final String APPID="order-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | public class Constant { 4 | public static final String APPID="order-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-wallet-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/serialization/ObjectSerializer.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.serialization; 2 | 3 | public interface ObjectSerializer { 4 | byte[] serialization(Object obj); 5 | T deserialize(byte[] bytes); 6 | } 7 | -------------------------------------------------------------------------------- /easytrans-dashboard/readme.md: -------------------------------------------------------------------------------- 1 | ## dashboard 2 | 本工程仅仅提供最基本的未完成事务查看、重试 以及 字符编码映射关系查询 3 | 4 | 若对功能有更多功能要求、美观性要求、访问安全性要求的 可参考本实现自行开发对应的dashboard,也欢迎自行开发后PR到本项目 5 | 6 | 1.3.0+以后dashboard可用,需要根据项目使用的RPC框架,调整对应代码配置 7 | 8 | 项目的关键依赖为MonitorConsumerFactory这个类 9 | 10 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-wallet-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-wallet-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-order-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-wallet-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | public class Constant { 4 | public static final String APPID="order-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-coupon-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | public class Constant { 4 | public static final String APPID="order-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-wallet-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-point-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/idempotent/IdempotentHandlerFilter.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.idempotent; 2 | 3 | import com.yiqiniu.easytrans.filter.EasyTransFilter; 4 | 5 | public interface IdempotentHandlerFilter extends EasyTransFilter{ 6 | 7 | } -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-wallet-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-order-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-order-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/interfacecallnozk-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | public class Constant { 4 | public static final String APPID="order-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/interfacecallnozk-wallet-api/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-order-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-order-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-order-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/monitor/StringCodecMonitor.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.monitor; 2 | 3 | /** 4 | * 5 | * @author deyou 6 | * 7 | */ 8 | public interface StringCodecMonitor extends EtMonitor { 9 | Object getString2IdMap(); 10 | } 11 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/interfacecallnozk-wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/WalletServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class WalletServiceApiConstant { 4 | public static final String APPID="wallet-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-order-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-order-api/src/main/java/com/yiqiniu/easytrans/demos/order/api/OrderServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.api; 2 | 3 | public class OrderServiceApiConstant { 4 | public static final String APPID="order-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/WalletServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class WalletServiceApiConstant { 4 | public static final String APPID="wallet-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-starter/src/main/java/com/yiqiniu/easytrans/EasyTransactionTrrigerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | @Configuration 6 | public class EasyTransactionTrrigerConfiguration { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-order-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/WalletServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class WalletServiceApiConstant { 4 | public static final String APPID="wallet-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/WalletServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class WalletServiceApiConstant { 4 | public static final String APPID="wallet-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/WalletServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class WalletServiceApiConstant { 4 | public static final String APPID="wallet-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/interfacecallnozk-order-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | .springBeans -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-coupon-service/.gitignore: -------------------------------------------------------------------------------- 1 | server_back.properties 2 | *.class 3 | *.log 4 | *.log.* 5 | .factorypath 6 | /target/* 7 | /.settings/* 8 | /bin/* 9 | /.project 10 | /.classpath 11 | /logs 12 | /target/ 13 | .DS_Store 14 | /.springBeans 15 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/WalletServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class WalletServiceApiConstant { 4 | public static final String APPID="wallet-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-coupon-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/CouponServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class CouponServiceApiConstant { 4 | public static final String APPID="coupon-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/WalletServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class WalletServiceApiConstant { 4 | public static final String APPID="wallet-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/interfacecallnozk-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/WalletServiceApiConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api; 2 | 3 | public class WalletServiceApiConstant { 4 | public static final String APPID="wallet-service"; 5 | } 6 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/RequestClassAware.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | public interface RequestClassAware { 4 | 5 | public static final String GET_REQUEST_CLASS = "getRequestClass"; 6 | 7 | Class> getRequestClass(); 8 | } 9 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/saga/AbstractSagaTccMethodRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.saga; 2 | 3 | public abstract class AbstractSagaTccMethodRequest implements SagaTccMethodRequest{ 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = 1L; 9 | } 10 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/monitor/EtMonitor.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.monitor; 2 | 3 | /** 4 | * 本接口用户表明某个接口是EasyTransaction的Monitor接口 5 | * 其只能被接口继承,否则不生效 6 | * Monitor的接口方法的入参请用简单类型,如字符串和数字,否则可能出现问题 7 | * 8 | * @author deyou 9 | * @date 2019.04.03 10 | */ 11 | public interface EtMonitor { 12 | } 13 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/ReliableMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | import com.yiqiniu.easytrans.protocol.MessageBusinessProvider; 4 | 5 | 6 | 7 | public interface ReliableMessageHandler

extends MessageBusinessProvider

{ 8 | } 9 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/BestEffortMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | import com.yiqiniu.easytrans.protocol.MessageBusinessProvider; 4 | 5 | 6 | 7 | public interface BestEffortMessageHandler

extends MessageBusinessProvider

{ 8 | } 9 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/stringcodec/ListableStringCodec.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.stringcodec; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author xu deyou 7 | * 8 | */ 9 | public interface ListableStringCodec extends StringCodec { 10 | Map> getMapStr2Id(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/AbstractReliableMessagePublishRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | 4 | public abstract class AbstractReliableMessagePublishRequest implements ReliableMessagePublishRequest{ 5 | 6 | /** 7 | * 8 | */ 9 | private static final long serialVersionUID = 1L; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/idgen/impl/ConstantBusinessCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.idgen.impl; 2 | 3 | import com.yiqiniu.easytrans.idgen.BusinessCodeGenerator; 4 | 5 | public class ConstantBusinessCodeGenerator implements BusinessCodeGenerator { 6 | @Override 7 | public String getCurrentBusinessCode() { 8 | return "default"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/readme.md: -------------------------------------------------------------------------------- 1 | # English 2 | ## rpc dubbo 3 | this demo show how to replace RPC implement with Alibaba Dubbo 4 | 5 | to run this demo, you will need zookeeper and mysql,change the configuration in applicaiton.yml,you can start the services 6 | 7 | 8 | # 中文 9 | ## rpc dubbo 10 | 本demo只演示了在本框架中改用DUBBO RPC实现 11 | 12 | 本demo运行起来需要zk以及关系数据库,修改applicaiton.yml文件里相关zk及数据库配置后,即可启动。 -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/monitor/TransactionLogMonitor.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.monitor; 2 | 3 | /** 4 | * 5 | * @author deyou 6 | * 7 | */ 8 | public interface TransactionLogMonitor extends EtMonitor { 9 | Object getUnfinishedLogs(int pageSize,Long latestTimeStamp); 10 | 11 | Object consistentProcess(String busCode, long trxId); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/tcc/AbstractTccMethodRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.tcc; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | 7 | public abstract class AbstractTccMethodRequest implements TccMethodRequest{ 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | } 14 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/queue/consumer/EasyTransMsgListener.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue.consumer; 2 | 3 | import java.util.Map; 4 | 5 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 6 | 7 | 8 | public interface EasyTransMsgListener { 9 | 10 | 11 | public EasyTransConsumeAction consume(Map header,EasyTransRequest message); 12 | } -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/queue/consumer/EasyTransConsumeAction.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue.consumer; 2 | 3 | public enum EasyTransConsumeAction { 4 | /** 5 | * consume success,process the next message 6 | */ 7 | CommitMessage, 8 | /** 9 | * consume fail, re-consume later,process the next message 10 | */ 11 | ReconsumeLater, 12 | } 13 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/autocps/AbstractAutoCpsMethodRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.autocps; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | 7 | public abstract class AbstractAutoCpsMethodRequest implements AutoCpsMethodRequest{ 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | } 14 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/AbstractBestEffortMessagePublishRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | 4 | /** 5 | * Best effort message 6 | */ 7 | public abstract class AbstractBestEffortMessagePublishRequest implements BestEffortMessagePublishRequest{ 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | } 14 | -------------------------------------------------------------------------------- /easytrans-rpc-rest-ribbon-starter/src/main/java/com/yiqiniu/easytrans/rpc/impl/rest/RestRibbonEasyTransConstants.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.rpc.impl.rest; 2 | 3 | public class RestRibbonEasyTransConstants { 4 | public static class HttpHeaderKey{ 5 | public static final String EASYTRANS_HEADER_KEY = "easyTransHeader"; 6 | } 7 | 8 | public static final String DEFAULT_URL_CONTEXT = "/easytrans"; 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/cps/AbstractCompensableMethodRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.cps; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | 7 | public abstract class AbstractCompensableMethodRequest implements CompensableMethodRequest{ 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | } 14 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/tcc/TccMethodRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.tcc; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.yiqiniu.easytrans.executor.TccMethodExecutor; 6 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 7 | 8 | public interface TccMethodRequest extends EasyTransRequest { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/util/ByteFormIdCodec.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.util; 2 | 3 | import com.yiqiniu.easytrans.protocol.TransactionId; 4 | 5 | public interface ByteFormIdCodec { 6 | 7 | byte[] getTransIdByte(TransactionId transId); 8 | 9 | byte[] getAppIdCeil(String appId); 10 | 11 | byte[] getAppIdFloor(String appId); 12 | 13 | TransactionId getTransIdFromByte(byte[] transId); 14 | 15 | } -------------------------------------------------------------------------------- /easytrans-rpc-dubbo-starter/src/main/java/com/yiqiniu/easytrans/rpc/impl/dubbo/DubboReferanceCustomizationer.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.rpc.impl.dubbo; 2 | 3 | import com.alibaba.dubbo.config.ReferenceConfig; 4 | import com.alibaba.dubbo.rpc.service.GenericService; 5 | 6 | public interface DubboReferanceCustomizationer { 7 | void customDubboReferance(String appId, String busCode,ReferenceConfig referenceConfig); 8 | } 9 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/EasyTransRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.yiqiniu.easytrans.executor.EasyTransExecutor; 6 | 7 | /** 8 | * base interface for soft transaction parameters
9 | */ 10 | public interface EasyTransRequest extends Serializable{ 11 | 12 | } 13 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/aft/AbstractAfterMasterTransRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.aft; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | 7 | public abstract class AbstractAfterMasterTransRequest implements AfterMasterTransRequest{ 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-dashboard/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Getting Started: Serving Web Content 5 | 6 | 7 | 8 | 获取字符串与其对应id的映射关系 9 | 获取未完成的事务记录 10 | 11 | 本界面过于简陋,求前端大牛协助优化 12 | 13 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/aft/AfterMasterTransRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.aft; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.yiqiniu.easytrans.executor.AfterTransMethodExecutor; 6 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 7 | 8 | public interface AfterMasterTransRequest extends EasyTransRequest { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/autocps/AutoCpsMethodRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.autocps; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.yiqiniu.easytrans.executor.AutoCpsMethodExecutor; 6 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 7 | 8 | public interface AutoCpsMethodRequest extends EasyTransRequest { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/cps/CompensableMethodRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.cps; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.yiqiniu.easytrans.executor.CompensableMethodExecutor; 6 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 7 | 8 | public interface CompensableMethodRequest extends EasyTransRequest { 9 | } 10 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/saga/SagaTccMethodRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.saga; 2 | 3 | import com.yiqiniu.easytrans.executor.SagaTccMethodExecutor; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | import com.yiqiniu.easytrans.protocol.SerializableVoid; 6 | 7 | public interface SagaTccMethodRequest extends EasyTransRequest { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/ReliableMessagePublishRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | import com.yiqiniu.easytrans.executor.ReliableMessageMethodExecutor; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | 6 | /** 7 | * transaction message 8 | */ 9 | public interface ReliableMessagePublishRequest extends EasyTransRequest{ 10 | } 11 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/context/event/GuardianProcessEndEventHandler.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.context.event; 2 | 3 | import com.yiqiniu.easytrans.context.LogProcessContext; 4 | 5 | 6 | public interface GuardianProcessEndEventHandler{ 7 | /** 8 | * 所有Log对应操作及登记的其他事件都执行完毕后,执行本方法 9 | * @param logCollection 10 | * @return 返回ture表示执行成功,返回false表示执行失败,等待下次重试 11 | */ 12 | boolean beforeProcessEnd(LogProcessContext logCollection); 13 | } -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/trx/TransactionFinishedContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.trx; 2 | 3 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 4 | 5 | 6 | public class TransactionFinishedContent extends DemiRightContent { 7 | 8 | private static final long serialVersionUID = 1L; 9 | 10 | @Override 11 | public int getLogType() { 12 | return ContentType.TransactionFininshed.getContentTypeId(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/monitor/MonitorConsumerFactory.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.monitor; 2 | 3 | /** 4 | * 5 | * @author deyou 6 | * @date 2019/04/02 7 | * 8 | */ 9 | public interface MonitorConsumerFactory { 10 | 11 | /** 12 | * use for methods to call 13 | * @param monitorInterface 14 | * @return 15 | */ 16 | public T getRemoteProxy(String appId, Class monitorInterface); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/queue/IdenticalQueueTopicMapper.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue; 2 | 3 | public class IdenticalQueueTopicMapper implements QueueTopicMapper { 4 | 5 | @Override 6 | public String[] mapToTopicTag(String appid, String busCode) { 7 | return new String[]{appid,busCode}; 8 | } 9 | 10 | @Override 11 | public String[] mapToAppIdBusCode(String topic, String tag) { 12 | return new String[]{topic,tag}; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/readme.md: -------------------------------------------------------------------------------- 1 | # English 2 | ## tcc-only 3 | this demo show an simple usage with REDIS log implement 4 | 5 | more usage you can refer to other demos or the UT case in easytrans-starter 6 | 7 | to run this demo, you will need zookeeper and mysql,change the configuration in applicaiton.yml,you can start the services 8 | 9 | 10 | # 中文 11 | ## tcc-only 12 | 本demo只演示了在本框架中如使用REDIS替代MYSQL作为日志存储 13 | 14 | 本demo运行起来需要zk、关系数据库及 REDIS,修改applicaiton.yml文件里相关zk及数据库配置后,即可启动。 -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/AbstractEasyTransRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.yiqiniu.easytrans.executor.EasyTransExecutor; 6 | 7 | 8 | 9 | public abstract class AbstractEasyTransRequest implements EasyTransRequest{ 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 1L; 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/queue/consumer/EasyTransMsgConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue.consumer; 2 | 3 | import java.util.Collection; 4 | 5 | 6 | public interface EasyTransMsgConsumer { 7 | 8 | /** 9 | * subscribe topic,override the previous subscription 10 | */ 11 | void subscribe(String topic, Collection tag,EasyTransMsgListener listener); 12 | 13 | void start(); 14 | 15 | String getConsumerId(); 16 | } -------------------------------------------------------------------------------- /easytrans-extensionsuite-database-starter/src/main/java/com/yiqiniu/easytrans/extensionsuite/impl/database/GetExtentionSuiteDatabase.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.extensionsuite.impl.database; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.transaction.PlatformTransactionManager; 6 | 7 | public interface GetExtentionSuiteDatabase { 8 | 9 | DataSource getDataSource(); 10 | 11 | PlatformTransactionManager getPlatformTransactionManager(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /easytrans-rpc-dubbo-starter/src/main/java/com/yiqiniu/easytrans/rpc/impl/dubbo/DubboServiceCustomizationer.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.rpc.impl.dubbo; 2 | 3 | import com.alibaba.dubbo.config.ServiceConfig; 4 | import com.alibaba.dubbo.rpc.service.GenericService; 5 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 6 | 7 | public interface DubboServiceCustomizationer { 8 | void customDubboService(BusinessIdentifer businessIdentifer,ServiceConfig serviceConfig); 9 | } 10 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/queue/producer/EasyTransMsgPublisher.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue.producer; 2 | 3 | import java.util.Map; 4 | 5 | public interface EasyTransMsgPublisher { 6 | 7 | /** 8 | * send message directory
9 | * 10 | * @param message 11 | * @return message sent info 12 | */ 13 | EasyTransMsgPublishResult publish(String topic, String tag, String key, Map header ,byte[] msgByte); 14 | } 15 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/AfterCommit.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo; 2 | 3 | import static java.lang.annotation.ElementType.TYPE; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * indicate the log is written after commit 11 | */ 12 | @Target({TYPE}) 13 | @Retention(RUNTIME) 14 | public @interface AfterCommit { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/AfterRollBack.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo; 2 | 3 | import static java.lang.annotation.ElementType.TYPE; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * indicate the log is written after roll back 11 | */ 12 | @Target({TYPE}) 13 | @Retention(RUNTIME) 14 | public @interface AfterRollBack { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/aft/AfterTransCalledContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.aft; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterCommit; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterCommit 7 | public class AfterTransCalledContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | @Override 12 | public int getLogType() { 13 | return ContentType.AfterTransCalled.getContentTypeId(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/tcc/TccCallConfirmedContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.tcc; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterCommit; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterCommit 7 | public class TccCallConfirmedContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | @Override 12 | public int getLogType() { 13 | return ContentType.TccCallConfirmed.getContentTypeId(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/compensable/CompensatedContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.compensable; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterRollBack; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterRollBack 7 | public class CompensatedContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | @Override 12 | public int getLogType() { 13 | return ContentType.Compensated.getContentTypeId(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/BestEffortMessagePublishRequest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | import com.yiqiniu.easytrans.executor.BestEffortMessageMethodExecutor; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | import com.yiqiniu.easytrans.protocol.SerializableVoid; 6 | 7 | /** 8 | * Best effort message 9 | */ 10 | public interface BestEffortMessagePublishRequest extends EasyTransRequest{ 11 | 12 | } 13 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/executor/RelativeInterface.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.executor; 2 | 3 | import static java.lang.annotation.ElementType.TYPE; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.Target; 8 | 9 | 10 | /** 11 | * the relative business implement interface 12 | */ 13 | @Target({TYPE}) 14 | @Retention(RUNTIME) 15 | public @interface RelativeInterface{ 16 | Class value(); 17 | } 18 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/tcc/TccCallCancelledContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.tcc; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterRollBack; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterRollBack 7 | public class TccCallCancelledContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | 12 | @Override 13 | public int getLogType() { 14 | return ContentType.TccCallCanceled.getContentTypeId(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/fescar/FescarAtCallCommitedContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.fescar; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterCommit; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterCommit 7 | public class FescarAtCallCommitedContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | @Override 12 | public int getLogType() { 13 | return ContentType.FescarAtCommited.getContentTypeId(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/saga/SagaTccCallConfirmedContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.saga; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterCommit; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterCommit 7 | public class SagaTccCallConfirmedContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | @Override 12 | public int getLogType() { 13 | return ContentType.SagaTccCallConfirmed.getContentTypeId(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/readme.md: -------------------------------------------------------------------------------- 1 | ## English 2 | this demo show how to get rid of any framework class in your business code(but the configuration code will still introduce the classes of framework), so that we can get a more pretty code style in our business code 3 | 4 | to run this demo, you will need zookeeper and mysql,change the configuration in applicaiton.yml,you can start the services 5 | 6 | 7 | ## Chinese 8 | 本DEMO演示了如何在业务代码里去掉任何框架的类的引用(但在配置代码里依然会引入框架代码),以此令业务代码达到更好的 解耦效果/代码风格 9 | 10 | 本demo运行起来需要zk以及关系数据库,修改applicaiton.yml文件里相关zk及数据库配置后,即可启动。 -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/readme.md: -------------------------------------------------------------------------------- 1 | # English 2 | ## tcc-only 3 | this demo show an simple usage with TCC 4 | 5 | more usage you can refer to other demos or the UT case in easytrans-starter 6 | 7 | to run this demo, you will need zookeeper and mysql,change the configuration in applicaiton.yml,you can start the services 8 | 9 | 10 | # 中文 11 | ## tcc-only 12 | 本demo只演示了在本框架中如何使用tcc以给大家一个如何在业务中使用本框架的整体认知。 13 | 14 | 更多的更复杂的用法 请参考easytrans-demos里其他目录(demo陆续加入中) 及 easytrans-starter里面的测试案例(用法最全,最复杂) 15 | 16 | 本demo运行起来需要zk以及关系数据库,修改applicaiton.yml文件里相关zk及数据库配置后,即可启动。 -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/saga/SagaTccCallCancelledContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.saga; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterRollBack; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterRollBack 7 | public class SagaTccCallCancelledContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | 12 | @Override 13 | public int getLogType() { 14 | return ContentType.SagaTccCallCanceled.getContentTypeId(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/readme.md: -------------------------------------------------------------------------------- 1 | # English 2 | ## tcc-only 3 | this demo show an simple usage with TCC 4 | 5 | more usage you can refer to other demos or the UT case in easytrans-starter 6 | 7 | to run this demo, you will need zookeeper and mysql,change the configuration in applicaiton.yml,you can start the services 8 | 9 | 10 | # 中文 11 | ## tcc-only 12 | 本demo只演示了在本框架中如何使用tcc以给大家一个如何在业务中使用本框架的整体认知。 13 | 14 | 更多的更复杂的用法 请参考easytrans-demos里其他目录(demo陆续加入中) 及 easytrans-starter里面的测试案例(用法最全,最复杂) 15 | 16 | 本demo运行起来需要zk以及关系数据库,修改applicaiton.yml文件里相关zk及数据库配置后,即可启动。 -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/mockservice/accounting/easytrans/AccountingApi.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.test.mockservice.accounting.easytrans; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | import com.yiqiniu.easytrans.test.mockservice.accounting.easytrans.AccountingCpsMethod.AccountingRequest; 6 | import com.yiqiniu.easytrans.test.mockservice.accounting.easytrans.AccountingCpsMethod.AccountingResponse; 7 | 8 | public interface AccountingApi { 9 | Future accounting(AccountingRequest request); 10 | } 11 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/fescar/FescarAtCallRollbackedContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.fescar; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterRollBack; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterRollBack 7 | public class FescarAtCallRollbackedContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | 12 | @Override 13 | public int getLogType() { 14 | return ContentType.FescarAtRollbacked.getContentTypeId(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/core/EasyTransFacade.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.core; 2 | 3 | import java.io.Serializable; 4 | import java.util.concurrent.Future; 5 | 6 | import com.yiqiniu.easytrans.executor.EasyTransExecutor; 7 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 8 | 9 | public interface EasyTransFacade { 10 | 11 | public void startEasyTrans(String busCode,long trxId); 12 | 13 | public

,E extends EasyTransExecutor, R extends Serializable> Future execute(P params); 14 | } 15 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/queue/QueueTopicMapper.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue; 2 | 3 | /** 4 | * 5 | * @author xudeyou 6 | * 7 | */ 8 | public interface QueueTopicMapper { 9 | 10 | /** 11 | * 12 | * @param appid 13 | * @param busCode 14 | * @return 字符串数组,第一个为topic,第二个为tag 15 | */ 16 | String[] mapToTopicTag(String appid, String busCode); 17 | 18 | /** 19 | * 20 | * @param topic 21 | * @param tag 22 | * @return 字符串数组,第一个为appId,第二个为busCode 23 | */ 24 | String[] mapToAppIdBusCode(String topic,String tag); 25 | } 26 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/idempotent/exception/ResultWrapperExeception.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.idempotent.exception; 2 | 3 | import com.yiqiniu.easytrans.filter.EasyTransResult; 4 | 5 | public class ResultWrapperExeception extends RuntimeException { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private EasyTransResult result; 10 | 11 | public ResultWrapperExeception(EasyTransResult result){ 12 | this.result = result; 13 | } 14 | 15 | public EasyTransResult getResult() { 16 | return result; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/provider/factory/ListableProviderFactory.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.provider.factory; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | public interface ListableProviderFactory { 7 | 8 | Set> getServiceRootKey(); 9 | 10 | Set> getServiceTransactionTypeSet(Class rootType); 11 | 12 | List getServices(Class root, Class transactionType); 13 | 14 | Object getService(String appId,String busCode); 15 | 16 | Class getServiceInterface(String appId,String busCode); 17 | } -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/DemiLeftContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo; 2 | 3 | 4 | 5 | /** 6 | * 需要找到匹配的另外半边的LOG 7 | */ 8 | public abstract class DemiLeftContent extends Content { 9 | 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = 1L; 14 | 15 | /** 16 | * 用于记录同一事务里,同一远程调用方法的调用顺序号 17 | */ 18 | private Integer callSeq; 19 | 20 | public Integer getCallSeq() { 21 | return callSeq; 22 | } 23 | 24 | public void setCallSeq(Integer callSeq) { 25 | this.callSeq = callSeq; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/DemiRightContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo; 2 | 3 | 4 | 5 | /** 6 | * LeftDemiContent的对应项 7 | */ 8 | public abstract class DemiRightContent extends Content { 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | 14 | 15 | private Integer leftDemiConentId; 16 | 17 | public Integer getLeftDemiConentId() { 18 | return leftDemiConentId; 19 | } 20 | 21 | public void setLeftDemiConentId(Integer leftDemiConentId) { 22 | this.leftDemiConentId = leftDemiConentId; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /easytrans-rpc-dubbo-starter/src/main/java/com/yiqiniu/easytrans/rpc/impl/dubbo/DubboEasyTransRpcProperties.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.rpc.impl.dubbo; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | /** 6 | * @author xudeyou 7 | */ 8 | 9 | @ConfigurationProperties(prefix="easytrans.rpc.dubbo") 10 | public class DubboEasyTransRpcProperties { 11 | 12 | private Boolean enabled; 13 | 14 | public Boolean getEnabled() { 15 | return enabled; 16 | } 17 | 18 | public void setEnabled(Boolean enabled) { 19 | this.enabled = enabled; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/rpc/EasyTransRpcConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.rpc; 2 | 3 | import java.io.Serializable; 4 | import java.util.Map; 5 | 6 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 7 | 8 | 9 | public interface EasyTransRpcConsumer { 10 |

,R extends Serializable> R call(String appId,String busCode,String innerMethod,Map header,P params); 11 |

,R extends Serializable> void callWithNoReturn(String appId,String busCode,String innerMethod,Map header,P params); 12 | } 13 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/executor/EasyTransExecutor.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.executor; 2 | 3 | import java.io.Serializable; 4 | import java.util.concurrent.Future; 5 | 6 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 7 | 8 | public interface EasyTransExecutor{ 9 | /** 10 | * 对不同补偿形式的方法进行调用处理 11 | * @param sameBusinessCallSeq 业务中多次调用同一个appId,busCode对应的业务时的顺序 12 | * @param params 调用对应的业务的参数 13 | * @return 14 | */ 15 |

,E extends EasyTransExecutor,R extends Serializable> Future execute(Integer sameBusinessCallSeq, P params); 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/idempotent/IdempotentTransactionDefinition.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.idempotent; 2 | 3 | import java.util.Map; 4 | 5 | import org.springframework.transaction.TransactionDefinition; 6 | 7 | import com.yiqiniu.easytrans.filter.EasyTransFilterChain; 8 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 9 | 10 | /** 11 | * 12 | * 用于控制幂等启动的事务的隔离级别等定义 13 | * @author xudeyou 14 | * 15 | */ 16 | public interface IdempotentTransactionDefinition { 17 | TransactionDefinition getTransactionDefinition(EasyTransFilterChain filterChain, Map header, EasyTransRequest request); 18 | } -------------------------------------------------------------------------------- /easytrans-starter/src/main/java/com/yiqiniu/easytrans/EnableEasyTransaction.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(EasyTransactionTrrigerConfiguration.class) 20 | public @interface EnableEasyTransaction { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/PublishResult.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | import java.io.Serializable; 4 | 5 | public class PublishResult implements Serializable { 6 | 7 | /** 8 | * 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | /** 12 | * when it's BestEffortMessage,it has no value 13 | */ 14 | private Integer messageContentId; 15 | 16 | public Integer getMessageContentId() { 17 | return messageContentId; 18 | } 19 | 20 | public void setMessageContentId(Integer messageContentId) { 21 | this.messageContentId = messageContentId; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/serialization/impl/SpringObjectSerialization.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.serialization.impl; 2 | 3 | import org.springframework.util.SerializationUtils; 4 | 5 | import com.yiqiniu.easytrans.serialization.ObjectSerializer; 6 | 7 | public class SpringObjectSerialization implements ObjectSerializer{ 8 | 9 | @Override 10 | public byte[] serialization(Object obj) { 11 | return SerializationUtils.serialize(obj); 12 | } 13 | 14 | @SuppressWarnings("unchecked") 15 | @Override 16 | public T deserialize(byte[] bytes) { 17 | return (T)SerializationUtils.deserialize(bytes); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /easytrans-queue-ons-starter/src/main/java/com/yiqiniu/easytrans/queue/impl/ons/EnableQueueOnsImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue.impl.ons; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(OnsQueueConfiguration.class) 20 | public @interface EnableQueueOnsImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class OrderApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(OrderApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class OrderApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(OrderApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-rpc-dubbo-starter/src/main/java/com/yiqiniu/easytrans/rpc/impl/dubbo/EnableRpcDubboImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.rpc.impl.dubbo; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(DubboEasyTransRpcConfiguration.class) 20 | public @interface EnableRpcDubboImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/master/impl/EnableMasterZookeeperImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.master.impl; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(ZookeeperMasterSelectorConfiguration.class) 20 | public @interface EnableMasterZookeeperImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class WalletApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(WalletApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class OrderApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(OrderApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-point-service/src/main/java/com/yiqiniu/easytrans/demos/point/impl/PointApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.point.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class PointApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(PointApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class WalletApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(WalletApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-log-redis-starter/src/main/java/com/yiqiniu/easytrans/log/impl/redis/EnableLogRedisImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.impl.redis; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(RedisTransactionLogConfiguration.class) 20 | public @interface EnableLogRedisImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-queue-kafka-starter/src/main/java/com/yiqiniu/easytrans/queue/impl/kafka/EnableQueueKafkaImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue.impl.kafka; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(KafkaQueueConfiguration.class) 20 | public @interface EnableQueueKafkaImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class OrderApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(OrderApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class WalletApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(WalletApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-queue-kafka-starter/src/main/java/com/yiqiniu/easytrans/queue/impl/kafka/QueueKafkaHelper.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue.impl.kafka; 2 | 3 | import com.yiqiniu.easytrans.core.EasytransConstant; 4 | 5 | public class QueueKafkaHelper { 6 | 7 | public static String getKafkaTopic(String topic,String tag){ 8 | return topic + EasytransConstant.EscapeChar + tag; 9 | } 10 | 11 | public static String[] getEasyTransTopicAndTag(String kafkaTopic){ 12 | String[] splited = kafkaTopic.split(EasytransConstant.EscapeChar); 13 | if(splited.length != 2){ 14 | throw new IllegalArgumentException("Error kafkaTopic Name:" + kafkaTopic); 15 | } 16 | return splited; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/stringcodec/impl/EnableStringCodecZookeeperImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.stringcodec.impl; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(ZookeeperStringCodecConfiguration.class) 20 | public @interface EnableStringCodecZookeeperImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class WalletApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(WalletApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | 9 | @SpringBootApplication 10 | @EnableEasyTransaction 11 | @EnableTransactionManagement 12 | public class WalletApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(WalletApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/readme.md: -------------------------------------------------------------------------------- 1 | # ENGLISH 2 | ## SAGA and reliable message 3 | This demo shows how to use TCC and reliable message composited transaction 4 | 5 | more usage you can refer to other demos or the UT case in easytrans-starter 6 | 7 | to run this demo, you will need zookeeper, kafka and mysql,change the configuration in applicaiton.yml,you can start the services 8 | 9 | ## Attention 10 | * SAGA-TCC transaction can only use in the master transaction 11 | 12 | # 中文 13 | ## sagat-tcc 14 | 本demo展示如何使用 TCC 以及 可靠消息 组成的混合事务 15 | 16 | 更多的更复杂的用法 请参考easytrans-demos里其他目录(demo陆续加入中) 及 easytrans-starter里面的测试案例(用法最全,最复杂) 17 | 18 | 本demo运行起来需要zookeeper,kafka以及mysql,修改applicaiton.yml文件里相关zk及数据库配置后,即可启动。 19 | -------------------------------------------------------------------------------- /easytrans-log-database-starter/src/main/java/com/yiqiniu/easytrans/log/impl/database/EnableLogDatabaseImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.impl.database; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(DataBaseTransactionLogConfiguration.class) 20 | public @interface EnableLogDatabaseImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-rpc-rest-ribbon-starter/src/main/java/com/yiqiniu/easytrans/rpc/impl/rest/EnableRpcRestRibbonImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.rpc.impl.rest; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(RestRibbonEasyTransRpcConfiguration.class) 20 | public @interface EnableRpcRestRibbonImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/context/MasterTransactionStatusVotter.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.context; 2 | 3 | public class MasterTransactionStatusVotter { 4 | 5 | private boolean commited = true; 6 | private Boolean transactionStatus; 7 | 8 | /** 9 | * 一票否决制度,只要有因素认为全局事务失败,则全局事务失败 10 | * one ballot veto 11 | */ 12 | public void veto() { 13 | commited = false; 14 | } 15 | 16 | public boolean getCurrentVoteStatusCommited() { 17 | return commited; 18 | } 19 | 20 | public Boolean getTransactionStatus() { 21 | return transactionStatus; 22 | } 23 | 24 | public void setTransactionStatus(Boolean transactionStatus) { 25 | this.transactionStatus = transactionStatus; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /easytrans-dashboard/src/main/resources/templates/string2IdMap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Getting Started: Serving Web Content 5 | 6 | 7 | 8 | 获取字符串与其对应id的映射关系 9 | 获取未完成的事务记录 10 | 11 |

12 | AppId 13 | 14 |
15 |
根据数字及ID可以反查在 事务日志、已执行事务、幂等信息 相关数据
16 |
17 |

18 |     
19 | 20 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/context/event/DemiLogEventHandler.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.context.event; 2 | 3 | import com.yiqiniu.easytrans.context.LogProcessContext; 4 | import com.yiqiniu.easytrans.log.vo.Content; 5 | 6 | public interface DemiLogEventHandler{ 7 | 8 | /** 9 | * 需要匹配出现的日志,成功匹配 10 | * @param logCtx 11 | * @param content 12 | * @return 返回ture表示执行成功,返回false表示执行失败,等待下次重试 13 | */ 14 | boolean onMatch(LogProcessContext logCtx, Content leftContent,Content rightContent); 15 | 16 | /** 17 | * 需要匹配出现的日志,匹配失败 18 | * @param logCollection 19 | * @return 返回ture表示执行成功,返回false表示执行失败,等待下次重试 20 | */ 21 | boolean onDismatch(LogProcessContext logCtx, Content leftContent); 22 | } -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/filter/EasyTransFilter.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.filter; 2 | 3 | import java.util.Map; 4 | 5 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 6 | 7 | 8 | public interface EasyTransFilter { 9 | 10 | /** 11 | * do invoke filter. 12 | * 13 | * 14 | * // before filter 15 | * Result result = invoker.invoke(invocation); 16 | * // after filter 17 | * return result; 18 | * 19 | * 20 | * @param invoker service 21 | * @param invocation invocation. 22 | * @return invoke result. 23 | */ 24 | EasyTransResult invoke(EasyTransFilterChain filterChain, Map header, EasyTransRequest request); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /easytrans-extensionsuite-database-starter/src/main/java/com/yiqiniu/easytrans/extensionsuite/impl/database/EnableExtensionSuiteDatabaseImpl.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.extensionsuite.impl.database; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.context.annotation.Import; 10 | 11 | /** 12 | * 13 | * @author xudeyou 14 | * 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Import(DatabaseExtensionsSuiteConfiguration.class) 20 | public @interface EnableExtensionSuiteDatabaseImpl { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/mockservice/notification/NotificationService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.test.mockservice.notification; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import com.yiqiniu.easytrans.protocol.BusinessProvider; 6 | import com.yiqiniu.easytrans.protocol.msg.EtBestEffortMsg; 7 | import com.yiqiniu.easytrans.test.mockservice.order.NotReliableOrderMessage; 8 | 9 | @Component 10 | public class NotificationService { 11 | 12 | @EtBestEffortMsg(idempotentType=BusinessProvider.IDENPOTENT_TYPE_BUSINESS) 13 | public void sendMsg(NotReliableOrderMessage msg){ 14 | System.out.println(String.format("user:%s used:%s", msg.getUserId(),msg.getAmount())); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/msg/MessageRecordContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.msg; 2 | 3 | import com.yiqiniu.easytrans.log.vo.DemiLeftContent; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | 6 | 7 | public class MessageRecordContent extends DemiLeftContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private EasyTransRequest params; 12 | 13 | public EasyTransRequest getParams() { 14 | return params; 15 | } 16 | 17 | public void setParams(EasyTransRequest message) { 18 | this.params = message; 19 | } 20 | 21 | @Override 22 | public int getLogType() { 23 | return ContentType.MessageRecord.getContentTypeId(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/autocps/AutoCpsLocalTransactionExecutor.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.autocps; 2 | 3 | import java.util.concurrent.Callable; 4 | 5 | import io.seata.core.context.RootContext; 6 | 7 | 8 | /** 9 | * 用于执行本地事务时,确保更新、Select for update等操作能获取正确值 10 | * 11 | * 本方法的执行要求AbstractFescarAtMethod已被初始化 12 | * @author deyou 13 | * 14 | */ 15 | public class AutoCpsLocalTransactionExecutor { 16 | 17 | public static R executeWithGlobalLockCheck(Callable call) throws Exception { 18 | try { 19 | RootContext.bind("Local Tranaction with Global lock support"); 20 | return call.call(); 21 | } finally { 22 | RootContext.unbind(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | import com.yiqiniu.easytrans.log.impl.redis.EnableLogRedisImpl; 9 | 10 | @SpringBootApplication 11 | @EnableEasyTransaction 12 | @EnableTransactionManagement 13 | @EnableLogRedisImpl 14 | public class OrderApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(OrderApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/msg/MessageSentContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.msg; 2 | 3 | import com.yiqiniu.easytrans.log.vo.AfterCommit; 4 | import com.yiqiniu.easytrans.log.vo.DemiRightContent; 5 | 6 | @AfterCommit 7 | public class MessageSentContent extends DemiRightContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private String remoteMessageId; 12 | 13 | @Override 14 | public int getLogType() { 15 | return ContentType.MessageSent.getContentTypeId(); 16 | } 17 | 18 | public String getRemoteMessageId() { 19 | return remoteMessageId; 20 | } 21 | 22 | public void setRemoteMessageId(String remoteMessageId) { 23 | this.remoteMessageId = remoteMessageId; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/aft/AfterTransCallRegisterContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.aft; 2 | 3 | import com.yiqiniu.easytrans.log.vo.DemiLeftContent; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | 6 | 7 | public class AfterTransCallRegisterContent extends DemiLeftContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private EasyTransRequest params; 12 | 13 | @Override 14 | public int getLogType() { 15 | return ContentType.AfterTransCallRegister.getContentTypeId(); 16 | } 17 | 18 | public EasyTransRequest getParams() { 19 | return params; 20 | } 21 | 22 | public void setParams(EasyTransRequest params) { 23 | this.params = params; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | import com.yiqiniu.easytrans.log.impl.redis.EnableLogRedisImpl; 9 | 10 | @SpringBootApplication 11 | @EnableEasyTransaction 12 | @EnableTransactionManagement 13 | @EnableLogRedisImpl 14 | public class WalletApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(WalletApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/compensable/PreCompensableCallContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.compensable; 2 | 3 | import com.yiqiniu.easytrans.log.vo.DemiLeftContent; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | 6 | 7 | public class PreCompensableCallContent extends DemiLeftContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private EasyTransRequest params; 12 | 13 | @Override 14 | public int getLogType() { 15 | return ContentType.PreCompensableCall.getContentTypeId(); 16 | } 17 | 18 | public EasyTransRequest getParams() { 19 | return params; 20 | } 21 | 22 | public void setParams(EasyTransRequest params) { 23 | this.params = params; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/tcc/PreTccCallContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.tcc; 2 | 3 | import com.yiqiniu.easytrans.log.vo.DemiLeftContent; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | 6 | 7 | public class PreTccCallContent extends DemiLeftContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | /** 12 | * 调用的参数 13 | */ 14 | private EasyTransRequest params; 15 | 16 | @Override 17 | public int getLogType() { 18 | return ContentType.PreTccCall.getContentTypeId(); 19 | } 20 | 21 | public EasyTransRequest getParams() { 22 | return params; 23 | } 24 | 25 | public void setParams(EasyTransRequest params) { 26 | this.params = params; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/stringcodec/StringCodec.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.stringcodec; 2 | 3 | /** 4 | * turn a repeated string to a id number 5 | * @author xu deyou 6 | * 7 | */ 8 | public interface StringCodec { 9 | 10 | /** 11 | * find the id for the value,if not found ,then encode and save it
12 | * 13 | * when the value is null,then it will return null 14 | * 15 | * @param stringType 16 | * @param value 17 | * @return 18 | */ 19 | Integer findId(String stringType, String value); 20 | 21 | /** 22 | * find the correspond string
23 | * it will throw exception when string not found 24 | * @param stringType 25 | * @param id 26 | * @return 27 | */ 28 | String findString(String stringType, int id); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/MessageBusinessProvider.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | import com.yiqiniu.easytrans.datasource.TransStatusLogger.TransactionStatus; 4 | import com.yiqiniu.easytrans.queue.consumer.EasyTransConsumeAction; 5 | 6 | 7 | public interface MessageBusinessProvider

> extends BusinessProvider

{ 8 | 9 | public static final String CONSUME = "consume"; 10 | 11 | //indicate isSynchronousMethod to be true,to save the return value 12 | @ExecuteOrder(doNotExecuteAfter = {}, ifNotExecutedReturnDirectly = {}, isSynchronousMethod=true) 13 | @MethodTransactionStatus(TransactionStatus.COMMITTED) 14 | public EasyTransConsumeAction consume(EasyTransRequest request); 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/fescar/FescarAtPreCallContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.fescar; 2 | 3 | import com.yiqiniu.easytrans.log.vo.DemiLeftContent; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | 6 | 7 | public class FescarAtPreCallContent extends DemiLeftContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | /** 12 | * 调用的参数 13 | */ 14 | private EasyTransRequest params; 15 | 16 | @Override 17 | public int getLogType() { 18 | return ContentType.FescarAtPreCall.getContentTypeId(); 19 | } 20 | 21 | public EasyTransRequest getParams() { 22 | return params; 23 | } 24 | 25 | public void setParams(EasyTransRequest params) { 26 | this.params = params; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/MethodTransactionStatus.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | import static java.lang.annotation.ElementType.METHOD; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * define the execute order of methods 11 | */ 12 | @Target({METHOD}) 13 | @Retention(RUNTIME) 14 | public @interface MethodTransactionStatus { 15 | 16 | /** 17 | * value of com.yiqiniu.easytrans.datasource.TransStatusLogger.TransactionStatus 18 | * 19 | * the default value -1 is invalid,keep the default value unchange will get an error in later processing 20 | * @return 21 | */ 22 | int value() default -1; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class OrderController { 11 | 12 | @Autowired 13 | private OrderService orderService; 14 | 15 | @RequestMapping("/buySth") 16 | @ResponseBody 17 | public Integer buySomething(@RequestParam int userId,@RequestParam int money){ 18 | return orderService.buySomething(userId, money); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class OrderController { 11 | 12 | @Autowired 13 | private OrderService orderService; 14 | 15 | @RequestMapping("/buySth") 16 | @ResponseBody 17 | public Integer buySomething(@RequestParam int userId,@RequestParam int money){ 18 | return orderService.buySomething(userId, money); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /easytrans-dashboard/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: easytrans-dashboard # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | 5 | server: 6 | port: 8888 7 | 8 | easytrans: 9 | recovery: 10 | enabled: false 11 | master: 12 | zk: 13 | enabled: false 14 | 15 | # RIBBON用,也可以直接开启Eureka 16 | order-service: 17 | ribbon: 18 | listOfServers: localhost:8080 19 | 20 | wallet-service: 21 | ribbon: 22 | listOfServers: localhost:8081 23 | 24 | # DUBBO 配置 25 | dubbo: 26 | application: 27 | name: easytrans-dashboard 28 | protocol: 29 | name: dubbo 30 | port: 20880 31 | registry: 32 | address: zookeeper://localhost:2281 33 | provider: 34 | timeout: 1000 35 | consumer: 36 | timeout: 1000 37 | 38 | 39 | debug: true -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class OrderController { 11 | 12 | @Autowired 13 | private OrderService orderService; 14 | 15 | @RequestMapping("/buySth") 16 | @ResponseBody 17 | public Integer buySomething(@RequestParam int userId,@RequestParam int money){ 18 | return orderService.buySomething(userId, money); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class OrderController { 11 | 12 | @Autowired 13 | private OrderService orderService; 14 | 15 | @RequestMapping("/buySth") 16 | @ResponseBody 17 | public Integer buySomething(@RequestParam int userId,@RequestParam int money){ 18 | 19 | return orderService.buySomething(userId, money); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/queue/producer/EasyTransMsgPublishResult.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.queue.producer; 2 | 3 | public class EasyTransMsgPublishResult { 4 | 5 | private String messageId; 6 | private String topic; 7 | 8 | 9 | public String getMessageId() { 10 | return messageId; 11 | } 12 | 13 | 14 | public void setMessageId(String messageId) { 15 | this.messageId = messageId; 16 | } 17 | 18 | public String getTopic() { 19 | return topic; 20 | } 21 | 22 | public void setTopic(String topic) { 23 | this.topic = topic; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "SendResult[topic=" + topic + ", messageId=" + messageId + ']'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class OrderController { 11 | 12 | @Autowired 13 | private OrderService orderService; 14 | 15 | @RequestMapping("/buySth") 16 | @ResponseBody 17 | public Integer buySomething(@RequestParam int userId,@RequestParam int money){ 18 | 19 | return orderService.buySomething(userId, money); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class OrderController { 11 | 12 | @Autowired 13 | private OrderService orderService; 14 | 15 | 16 | @RequestMapping("/buySth") 17 | @ResponseBody 18 | public Integer buySomething(@RequestParam int userId,@RequestParam int money){ 19 | return orderService.buySomething(userId, money); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-coupon-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/CouponController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class CouponController { 11 | 12 | @Autowired 13 | private CouponService couponService; 14 | 15 | @RequestMapping("/couponCount") 16 | @ResponseBody 17 | public Integer buySomething(@RequestParam int userId) throws Exception{ 18 | return couponService.getExcatCouponCount(userId); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class OrderController { 11 | 12 | @Autowired 13 | private OrderService orderService; 14 | 15 | 16 | @RequestMapping("/buySth") 17 | @ResponseBody 18 | public String buySomethingProxy(@RequestParam int userId,@RequestParam int money){ 19 | return orderService.buySomething(userId, money); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/idempotent/DefaultIdempotentTransactionDefinition.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.idempotent; 2 | 3 | import java.util.Map; 4 | 5 | import org.springframework.transaction.TransactionDefinition; 6 | import org.springframework.transaction.support.DefaultTransactionDefinition; 7 | 8 | import com.yiqiniu.easytrans.filter.EasyTransFilterChain; 9 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 10 | 11 | public class DefaultIdempotentTransactionDefinition implements IdempotentTransactionDefinition { 12 | 13 | @Override 14 | public TransactionDefinition getTransactionDefinition(EasyTransFilterChain filterChain, Map header, 15 | EasyTransRequest request) { 16 | return new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/interfacecallnozk-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.transaction.annotation.EnableTransactionManagement; 6 | 7 | import com.yiqiniu.easytrans.EnableEasyTransaction; 8 | import com.yiqiniu.easytrans.extensionsuite.impl.database.EnableExtensionSuiteDatabaseImpl; 9 | 10 | @SpringBootApplication 11 | @EnableExtensionSuiteDatabaseImpl 12 | @EnableEasyTransaction 13 | @EnableTransactionManagement 14 | public class WalletApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(WalletApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/interfacecallnozk-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | @Controller 10 | public class OrderController { 11 | 12 | @Autowired 13 | private OrderService orderService; 14 | 15 | 16 | @RequestMapping("/buySth") 17 | @ResponseBody 18 | public String buySomethingProxy(@RequestParam int userId,@RequestParam int money){ 19 | return orderService.buySomething(userId, money); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/filter/EasyTransFilterChainFactory.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.filter; 2 | 3 | import java.util.List; 4 | 5 | public interface EasyTransFilterChainFactory { 6 | 7 | /** 8 | * get default filter chain
9 | * RPC,Queue Implement should wrap the user business code to a filter,and then add to the chain end
10 | * so before execute the user business code,we filter the request 11 | * @param appId 12 | * @param busCode 13 | * @param innerMethod 14 | * @return 15 | */ 16 | EasyTransFilterChain getDefaultFilterChain(String appId,String busCode,String innerMethod); 17 | 18 | EasyTransFilterChain getFilterChainByFilters(String appId,String busCode,String innerMethod,List filters); 19 | 20 | List getDefaultFilters(); 21 | } 22 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/TransactionLogWritter.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log; 2 | 3 | import java.util.List; 4 | 5 | import com.yiqiniu.easytrans.log.vo.Content; 6 | 7 | /** 8 | * Because in TransactionLogReader will find unfinished transaction logs, 9 | * so the writer implement should record which transaction does not end. 10 | */ 11 | public interface TransactionLogWritter { 12 | 13 | /** 14 | * append logs to specific transaction 15 | * @param appId 16 | * @param busCode unique busCode in appId 17 | * @param trxId unique trxId in appId+busCode 18 | * @param newOrderedContent appending logs 19 | * @param finished is the transaction log complete. 20 | */ 21 | void appendTransLog(String appId,String busCode,long trxId,List newOrderedContent,boolean finished); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/master/impl/ZookeeperMasterSelectorProperties.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.master.impl; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | /** 6 | * @author xudeyou 7 | */ 8 | 9 | @ConfigurationProperties(prefix="easytrans.master.zk") 10 | public class ZookeeperMasterSelectorProperties { 11 | 12 | private Boolean enabled; 13 | 14 | private String zooKeeperUrl; 15 | 16 | public String getZooKeeperUrl() { 17 | return zooKeeperUrl; 18 | } 19 | 20 | public void setZooKeeperUrl(String zooKeeperUrl) { 21 | this.zooKeeperUrl = zooKeeperUrl; 22 | } 23 | 24 | public Boolean getEnabled() { 25 | return enabled; 26 | } 27 | 28 | public void setEnabled(Boolean enabled) { 29 | this.enabled = enabled; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/stringcodec/impl/ZookeeperStringCodecProperties.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.stringcodec.impl; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | /** 6 | * @author xudeyou 7 | */ 8 | 9 | @ConfigurationProperties(prefix="easytrans.stringcodec.zk") 10 | public class ZookeeperStringCodecProperties { 11 | 12 | private Boolean enabled; 13 | 14 | private String zooKeeperUrl; 15 | 16 | public String getZooKeeperUrl() { 17 | return zooKeeperUrl; 18 | } 19 | 20 | public void setZooKeeperUrl(String zooKeeperUrl) { 21 | this.zooKeeperUrl = zooKeeperUrl; 22 | } 23 | 24 | public Boolean getEnabled() { 25 | return enabled; 26 | } 27 | 28 | public void setEnabled(Boolean enabled) { 29 | this.enabled = enabled; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/BusinessIdentifer.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | import static java.lang.annotation.ElementType.TYPE; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.Target; 8 | 9 | 10 | /** 11 | * this should add to every concrete EasyTransRequest implement 12 | */ 13 | @Target({TYPE}) 14 | @Retention(RUNTIME) 15 | public @interface BusinessIdentifer{ 16 | 17 | /** 18 | * find module by appId 19 | */ 20 | String appId(); 21 | 22 | /** 23 | * find service in module by busCode 24 | * @return 25 | */ 26 | String busCode(); 27 | 28 | /** 29 | * RPC call timeout(milliseconds). 30 | * 0 for default setting 31 | * @return 32 | */ 33 | int rpcTimeOut() default 0; 34 | } 35 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/rpc/EasyTransRpcProvider.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.rpc; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.yiqiniu.easytrans.filter.EasyTransFilter; 7 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 8 | import com.yiqiniu.easytrans.protocol.RpcBusinessProvider; 9 | 10 | public interface EasyTransRpcProvider { 11 | /** 12 | * start the service list offered 13 | * @param businessInterface the service interface 14 | * @param businessList detailServiceImpl 15 | */ 16 | void startService(Class businessInterface,Map> businessList); 17 | 18 | /** 19 | * add EasyTransFilter to RPC filters 20 | * @param filters ordered filter 21 | */ 22 | void addEasyTransFilter(List filters); 23 | } 24 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/TransactionLogReader.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import com.yiqiniu.easytrans.log.vo.LogCollection; 7 | import com.yiqiniu.easytrans.protocol.TransactionId; 8 | 9 | public interface TransactionLogReader { 10 | 11 | /** 12 | * 获取当前服务的未完成的日志 13 | * get current service's unfinished logs 14 | * @param locationId can be null 15 | * @param pageSize 16 | * @param createTimeCeiling 17 | * @return 18 | */ 19 | List getUnfinishedLogs(LogCollection locationId,int pageSize,Date createTimeCeiling); 20 | 21 | /** 22 | * 获取当前服务的未完成的日志 23 | * get current service's unfinished logs by id 24 | * @param ids transaction ids 25 | * @return 26 | */ 27 | List getTransactionLogById(List ids); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /easytrans-extensionsuite-database-starter/src/main/java/com/yiqiniu/easytrans/extensionsuite/impl/database/DatabaseSnowFlakeIdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.extensionsuite.impl.database; 2 | 3 | import java.util.concurrent.ConcurrentHashMap; 4 | 5 | import com.yiqiniu.easytrans.idgen.TrxIdGenerator; 6 | import com.yiqiniu.easytrans.idgen.impl.SnowFlake; 7 | 8 | public class DatabaseSnowFlakeIdGenerator implements TrxIdGenerator { 9 | 10 | private long hostSeq; 11 | private ConcurrentHashMap mapSnowFlakers = new ConcurrentHashMap<>(); 12 | 13 | 14 | public DatabaseSnowFlakeIdGenerator(long hostSeq) { 15 | this.hostSeq = hostSeq % (long)(Math.pow(2, SnowFlake.MACHINE_BIT)); 16 | } 17 | 18 | 19 | @Override 20 | public long getCurrentTrxId(String busCode) { 21 | SnowFlake s = mapSnowFlakers.computeIfAbsent(busCode, k->new SnowFlake(hostSeq)); 22 | return s.nextId(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/trx/TransactionBeginContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.trx; 2 | 3 | import com.yiqiniu.easytrans.log.vo.DemiLeftContent; 4 | 5 | 6 | public class TransactionBeginContent extends DemiLeftContent { 7 | 8 | private static final long serialVersionUID = 1L; 9 | 10 | private String pTrxAppId;//上级事务所在的App 11 | 12 | private String pTrxId;//上级事务所在的trxId 13 | 14 | 15 | @Override 16 | public int getLogType() { 17 | return ContentType.TransactionBegin.getContentTypeId(); 18 | } 19 | 20 | public String getpTrxAppId() { 21 | return pTrxAppId; 22 | } 23 | 24 | public void setpTrxAppId(String pTrxAppId) { 25 | this.pTrxAppId = pTrxAppId; 26 | } 27 | 28 | public String getpTrxId() { 29 | return pTrxId; 30 | } 31 | 32 | public void setpTrxId(String pTrxId) { 33 | this.pTrxId = pTrxId; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /easytrans-extensionsuite-database-starter/readme.md: -------------------------------------------------------------------------------- 1 | ## distruibute transaction election relation database implement 2 | 3 | 4 | create table in mysql, it's not necessary to use the same database of business(but you can use the same one). 5 | 6 | CREATE TABLE `election` ( 7 | `app_id` varchar(64) NOT NULL COMMENT 'AppId', 8 | `instance_id` int(11) NOT NULL COMMENT '实例id,递增', 9 | `heart_beat_time` datetime NOT NULL COMMENT '上次master发送心跳的时间', 10 | `instance_name` varchar(255) DEFAULT NULL COMMENT '当前实例的名称', 11 | PRIMARY KEY (`app_id`,`instance_id`) 12 | ) ENGINE=InnoDB ; 13 | 14 | 15 | CREATE TABLE `str_codec` ( 16 | `key_int` int(11) NOT NULL, 17 | `type_str` varchar(45) NOT NULL, 18 | `value_str` varchar(2000) NOT NULL, 19 | `create_time` datetime NOT NULL, 20 | PRIMARY KEY (`key_int`), 21 | UNIQUE KEY `str_type_UNIQUE` (`type_str`,`value_str`) 22 | ) ENGINE=InnoDB; 23 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/log/vo/saga/PreSagaTccCallContent.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.vo.saga; 2 | 3 | import com.yiqiniu.easytrans.log.vo.DemiLeftContent; 4 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 5 | 6 | 7 | public class PreSagaTccCallContent extends DemiLeftContent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | /** 12 | * 调用的参数 13 | */ 14 | private EasyTransRequest params; 15 | 16 | @Override 17 | public int getLogType() { 18 | return ContentType.PreSagaTccCall.getContentTypeId(); 19 | } 20 | 21 | public EasyTransRequest getParams() { 22 | return params; 23 | } 24 | 25 | public void setParams(EasyTransRequest params) { 26 | this.params = params; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "PreSagaTccCallContent [params=" + params + "]"; 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/requestcfg/WalletPayRequestCfg.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api.requestcfg; 2 | 3 | import com.yiqiniu.easytrans.demos.wallet.api.WalletPayMoneyService.WalletPayRequestVO; 4 | import com.yiqiniu.easytrans.demos.wallet.api.WalletPayMoneyService.WalletPayResponseVO; 5 | import com.yiqiniu.easytrans.demos.wallet.api.WalletServiceApiConstant; 6 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 7 | import com.yiqiniu.easytrans.protocol.tcc.TccMethodRequest; 8 | 9 | /** 10 | * define the calling configuration for WalletPayMoneyService 11 | */ 12 | @BusinessIdentifer(appId=WalletServiceApiConstant.APPID,busCode="pay",rpcTimeOut=2000) 13 | public class WalletPayRequestCfg extends WalletPayRequestVO implements TccMethodRequest{ 14 | private static final long serialVersionUID = 1L; 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call-nozk/interfacecallnozk-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/requestcfg/WalletPayRequestCfg.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api.requestcfg; 2 | 3 | import com.yiqiniu.easytrans.demos.wallet.api.WalletPayMoneyService.WalletPayRequestVO; 4 | import com.yiqiniu.easytrans.demos.wallet.api.WalletPayMoneyService.WalletPayResponseVO; 5 | import com.yiqiniu.easytrans.demos.wallet.api.WalletServiceApiConstant; 6 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 7 | import com.yiqiniu.easytrans.protocol.tcc.TccMethodRequest; 8 | 9 | /** 10 | * define the calling configuration for WalletPayMoneyService 11 | */ 12 | @BusinessIdentifer(appId=WalletServiceApiConstant.APPID,busCode="pay",rpcTimeOut=2000) 13 | public class WalletPayRequestCfg extends WalletPayRequestVO implements TccMethodRequest{ 14 | private static final long serialVersionUID = 1L; 15 | } 16 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/monitor/server/ServerSideStringCodecMonitor.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.monitor.server; 2 | 3 | import com.yiqiniu.easytrans.monitor.StringCodecMonitor; 4 | import com.yiqiniu.easytrans.stringcodec.ListableStringCodec; 5 | import com.yiqiniu.easytrans.stringcodec.StringCodec; 6 | 7 | public class ServerSideStringCodecMonitor implements StringCodecMonitor { 8 | 9 | 10 | private StringCodec stringCodec; 11 | 12 | public ServerSideStringCodecMonitor(StringCodec stringCodec) { 13 | super(); 14 | this.stringCodec = stringCodec; 15 | } 16 | 17 | @Override 18 | public Object getString2IdMap() { 19 | 20 | if(stringCodec instanceof ListableStringCodec) { 21 | ListableStringCodec lsc = (ListableStringCodec) stringCodec; 22 | return lsc.getMapStr2Id(); 23 | } 24 | 25 | return null; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/core/LogProcessor.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.core; 2 | 3 | import com.yiqiniu.easytrans.context.LogProcessContext; 4 | import com.yiqiniu.easytrans.log.vo.Content; 5 | 6 | /** 7 | * the processor for each log 8 | */ 9 | public interface LogProcessor { 10 | 11 | /** 12 | * the process method for specified log type 13 | * @param ctx log processing context 14 | * @param currentContent processing content 15 | * @return true for success,false for end processing and retry later 16 | */ 17 | boolean logProcess(LogProcessContext ctx,Content currentContent); 18 | 19 | /** 20 | * the pre-process method for specified log type 21 | * @param ctx log processing context 22 | * @param currentContent processing content 23 | * @return true for success,false for end processing and retry later 24 | */ 25 | boolean preLogProcess(LogProcessContext ctx,Content currentContent); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/master/EasyTransMasterSelector.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.master; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | public interface EasyTransMasterSelector { 6 | 7 | /** 8 | * whether this job has the leadership 9 | * @return 10 | */ 11 | boolean hasLeaderShip(); 12 | 13 | /** 14 | * wait till taken LeaderShip or closed. 15 | * it should used cooperate with hasLeaderShip 16 | * @throws InterruptedException 17 | */ 18 | public void await() throws InterruptedException; 19 | 20 | /** 21 | * Causes the current thread to wait until this instance acquires leadership unless 22 | * the thread is interrupted, the specified waiting time elapses or the instance is closed. 23 | * @param timeout 24 | * @param unit 25 | * @return 26 | * @throws InterruptedException 27 | */ 28 | public boolean await(long timeout, TimeUnit unit) throws InterruptedException; 29 | } 30 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/BusinessProvider.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | public interface BusinessProvider

>{ 4 | 5 | public static final String GET_IDEMPOTENT_TYPE = "getIdempotentType"; 6 | 7 | /** 8 | * Idempotent implement by Framework code
9 | * this will take extract performance cost,but it will help decrease the complexity of business
10 | */ 11 | public static final int IDENPOTENT_TYPE_FRAMEWORK = 0; 12 | 13 | /** 14 | * Idempotent implement by Business code
15 | * this will take extract develop cost in business,but it will help increase the performance 16 | */ 17 | public static final int IDENPOTENT_TYPE_BUSINESS = 1; 18 | 19 | /** 20 | * idempotent type declare. 21 | * IDENPOTENT_TYPE_FRAMEWORK = 0 22 | * IDENPOTENT_TYPE_BUSINESS = 1 23 | * @return 24 | */ 25 | int getIdempotentType(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-point-service/src/main/java/com/yiqiniu/easytrans/demos/point/impl/PointService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.point.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | import com.yiqiniu.easytrans.demos.order.api.vo.OrderFinishedMessage; 10 | 11 | @Component 12 | public class PointService { 13 | 14 | @Resource 15 | private JdbcTemplate jdbcTemplate; 16 | 17 | @Transactional 18 | public void addPointForBuying(OrderFinishedMessage msg){ 19 | int update = jdbcTemplate.update("update `point` set point = point + ? where user_id = ?;", 20 | msg.getOrderAmt(),msg.getUserId()); 21 | 22 | if(update != 1){ 23 | throw new RuntimeException("can not find specific user id!"); 24 | } 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/aft/AfterMasterTransMethod.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.aft; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.yiqiniu.easytrans.datasource.TransStatusLogger.TransactionStatus; 6 | import com.yiqiniu.easytrans.protocol.MethodTransactionStatus; 7 | import com.yiqiniu.easytrans.protocol.RpcBusinessProvider; 8 | 9 | /** 10 | * This will help implement the situation such as:
11 | *
12 | * Write and commit a record to database to mark the execute of an RPC and then execute the RPC
13 | * 14 | * Methods here should be idempotent 15 | */ 16 | public interface AfterMasterTransMethod

, R extends Serializable> extends RpcBusinessProvider

{ 17 | 18 | public static final String AFTER_TRANSACTION = "afterTransaction"; 19 | 20 | @MethodTransactionStatus(TransactionStatus.COMMITTED) 21 | R afterTransaction(P param); 22 | } 23 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-coupon-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/UseCouponAutoCpsService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.demos.wallet.api.vo.UseCouponVO.UseCouponMethodRequest; 8 | import com.yiqiniu.easytrans.demos.wallet.api.vo.UseCouponVO.UseCouponResult; 9 | import com.yiqiniu.easytrans.protocol.autocps.AbstractAutoCpsMethod; 10 | 11 | @Component 12 | public class UseCouponAutoCpsService extends AbstractAutoCpsMethod{ 13 | 14 | @Resource 15 | private CouponService couponService; 16 | 17 | @Override 18 | public int getIdempotentType() { 19 | return IDENPOTENT_TYPE_FRAMEWORK; 20 | } 21 | 22 | @Override 23 | protected UseCouponResult doBusiness(UseCouponMethodRequest param) { 24 | return couponService.useCoupon(param); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /easytrans-extensionsuite-database-starter/src/main/java/com/yiqiniu/easytrans/extensionsuite/impl/database/DefaultGetExtensionSuiteDatasource.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.extensionsuite.impl.database; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.transaction.PlatformTransactionManager; 6 | 7 | 8 | public class DefaultGetExtensionSuiteDatasource implements GetExtentionSuiteDatabase{ 9 | 10 | public DefaultGetExtensionSuiteDatasource(DataSource dataSource, PlatformTransactionManager transManager) { 11 | super(); 12 | this.dataSource = dataSource; 13 | this.transManager = transManager; 14 | } 15 | 16 | private DataSource dataSource; 17 | private PlatformTransactionManager transManager; 18 | 19 | @Override 20 | public DataSource getDataSource() { 21 | return dataSource; 22 | } 23 | 24 | @Override 25 | public PlatformTransactionManager getPlatformTransactionManager() { 26 | return transManager; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-order-api/src/main/java/com/yiqiniu/easytrans/demos/order/api/vo/OrderFinishedMessage.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.api.vo; 2 | 3 | import com.yiqiniu.easytrans.demos.order.api.OrderServiceApiConstant; 4 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 5 | import com.yiqiniu.easytrans.protocol.msg.ReliableMessagePublishRequest; 6 | 7 | @BusinessIdentifer(appId=OrderServiceApiConstant.APPID,busCode="orderFinished") 8 | public class OrderFinishedMessage implements ReliableMessagePublishRequest { 9 | 10 | private static final long serialVersionUID = 1L; 11 | 12 | private Integer userId; 13 | 14 | private Long orderAmt; 15 | 16 | public Long getOrderAmt() { 17 | return orderAmt; 18 | } 19 | 20 | public void setOrderAmt(Long orderAmt) { 21 | this.orderAmt = orderAmt; 22 | } 23 | 24 | public Integer getUserId() { 25 | return userId; 26 | } 27 | 28 | public void setUserId(Integer userId) { 29 | this.userId = userId; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /easytrans-log-redis-starter/src/main/java/com/yiqiniu/easytrans/log/impl/redis/RedisTransactionLogProperties.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.impl.redis; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | /** 6 | * @author xudeyou 7 | */ 8 | 9 | @ConfigurationProperties(prefix="easytrans.log.redis") 10 | public class RedisTransactionLogProperties { 11 | private Boolean enabled; 12 | private String redisUri; 13 | private String keyPrefix = ""; 14 | 15 | public Boolean getEnabled() { 16 | return enabled; 17 | } 18 | 19 | public void setEnabled(Boolean enabled) { 20 | this.enabled = enabled; 21 | } 22 | 23 | public String getRedisUri() { 24 | return redisUri; 25 | } 26 | 27 | public void setRedisUri(String redisUri) { 28 | this.redisUri = redisUri; 29 | } 30 | 31 | public String getKeyPrefix() { 32 | return keyPrefix; 33 | } 34 | 35 | public void setKeyPrefix(String keyPrefix) { 36 | this.keyPrefix = keyPrefix; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/mockservice/order/OrderMessage.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.test.mockservice.order; 2 | 3 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 4 | import com.yiqiniu.easytrans.protocol.msg.ReliableMessagePublishRequest; 5 | import com.yiqiniu.easytrans.test.Constant; 6 | 7 | @BusinessIdentifer(appId=Constant.APPID + "Test",busCode=OrderMessage.BUSINESS_CODE) 8 | public class OrderMessage implements ReliableMessagePublishRequest { 9 | 10 | public static final String BUSINESS_CODE = "ReliableOrderMsg"; 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 1L; 15 | 16 | private Integer userId; 17 | private Long amount; 18 | 19 | public Integer getUserId() { 20 | return userId; 21 | } 22 | 23 | public void setUserId(Integer userId) { 24 | this.userId = userId; 25 | } 26 | 27 | public Long getAmount() { 28 | return amount; 29 | } 30 | 31 | public void setAmount(Long amount) { 32 | this.amount = amount; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/filter/EasyTransFilterChain.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.filter; 2 | 3 | import java.util.Map; 4 | 5 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 6 | 7 | public interface EasyTransFilterChain { 8 | 9 | String MESSAGE_BUSINESS_FLAG = "consume"; 10 | 11 | String getAppId(); 12 | 13 | String getBusCode(); 14 | 15 | String getInnerMethodName(); 16 | 17 | void addFilter(EasyTransFilter filter); 18 | 19 | /** 20 | * invoke filter chain 21 | * 22 | * @param invocation 23 | * @return result 24 | */ 25 | EasyTransResult invokeFilterChain(Map header,EasyTransRequest request); 26 | 27 | /** 28 | * 29 | * @param key 30 | * @param resource origin resource 31 | * @return 32 | */ 33 | Object bindResource(String key,Object resource); 34 | 35 | /** 36 | * get bound resource 37 | * @param key 38 | * @return 39 | */ 40 | T getResource(String key); 41 | } -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/core/EasytransConstant.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.core; 2 | /** 3 | * @author xudeyou 4 | */ 5 | public class EasytransConstant { 6 | 7 | public static class PropertiesKeys { 8 | public static final String APPLICATION_NAME_KEY = "spring.application.name"; 9 | } 10 | 11 | public static class CallHeadKeys { 12 | public static final String PARENT_TRX_ID_KEY = "pTrxId"; 13 | public static final String CALL_SEQ = "cseq"; 14 | public static final String PARENT_TRANSACTION_STATUS = "pTrxSts"; 15 | } 16 | 17 | public static class StringCodecKeys{ 18 | public static final String APP_ID = "APP_ID"; 19 | public static final String BUSINESS_CODE = "BUS_CODE"; 20 | public static final String METHOD_NAME = "METHOD_NAME"; 21 | } 22 | 23 | public final static String EscapeChar = "_"; 24 | 25 | public static class DataSourceRelative { 26 | public static final String DATA_SOURCE = "RELATIVE_DS"; 27 | public static final String TRANSACTION_MANAGER = "RELATIVE_TM"; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /easytrans-queue-kafka-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | EasyTransaction queue kafka implement 4 | 5 | easytrans-queue-kafka-starter 6 | 7 | 8 | com.yiqiniu.easytrans 9 | easytrans 10 | ${revision} 11 | ../pom.xml 12 | 13 | 14 | 15 | UTF-8 16 | 17 | 18 | 19 | 20 | com.yiqiniu.easytrans 21 | easytrans-core 22 | 23 | 24 | 25 | org.apache.kafka 26 | kafka-clients 27 | 1.0.0 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/mockservice/order/NotReliableOrderMessage.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.test.mockservice.order; 2 | 3 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 4 | import com.yiqiniu.easytrans.protocol.msg.BestEffortMessagePublishRequest; 5 | import com.yiqiniu.easytrans.test.Constant; 6 | 7 | @BusinessIdentifer(appId=Constant.APPID,busCode=NotReliableOrderMessage.BUSINESS_CODE) 8 | public class NotReliableOrderMessage implements BestEffortMessagePublishRequest { 9 | 10 | public static final String BUSINESS_CODE = "NotReliableOrderMsg"; 11 | 12 | /** 13 | * 14 | */ 15 | private static final long serialVersionUID = 1L; 16 | 17 | private Integer userId; 18 | private Long amount; 19 | 20 | public Integer getUserId() { 21 | return userId; 22 | } 23 | 24 | public void setUserId(Integer userId) { 25 | this.userId = userId; 26 | } 27 | 28 | public Long getAmount() { 29 | return amount; 30 | } 31 | 32 | public void setAmount(Long amount) { 33 | this.amount = amount; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/mockservice/order/OrderMessageForCascadingTest.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.test.mockservice.order; 2 | 3 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 4 | import com.yiqiniu.easytrans.protocol.msg.ReliableMessagePublishRequest; 5 | import com.yiqiniu.easytrans.test.Constant; 6 | 7 | @BusinessIdentifer(appId=Constant.APPID,busCode=OrderMessageForCascadingTest.BUSINESS_CODE) 8 | public class OrderMessageForCascadingTest implements ReliableMessagePublishRequest { 9 | 10 | public static final String BUSINESS_CODE = "ReliableOrderMsgCascade"; 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 1L; 15 | 16 | private Integer userId; 17 | private Long amount; 18 | 19 | public Integer getUserId() { 20 | return userId; 21 | } 22 | 23 | public void setUserId(Integer userId) { 24 | this.userId = userId; 25 | } 26 | 27 | public Long getAmount() { 28 | return amount; 29 | } 30 | 31 | public void setAmount(Long amount) { 32 | this.amount = amount; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletPaySagaTccService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayRequestVO; 8 | import com.yiqiniu.easytrans.protocol.saga.SagaTccMethod; 9 | 10 | @Component 11 | public class WalletPaySagaTccService implements SagaTccMethod{ 12 | 13 | @Resource 14 | private WalletService wlletService; 15 | 16 | @Override 17 | public int getIdempotentType() { 18 | return IDENPOTENT_TYPE_FRAMEWORK; 19 | } 20 | 21 | @Override 22 | public void sagaTry(WalletPayRequestVO param) { 23 | wlletService.doTryPay(param); 24 | } 25 | 26 | @Override 27 | public void sagaConfirm(WalletPayRequestVO param) { 28 | wlletService.doConfirmPay(param); 29 | } 30 | 31 | @Override 32 | public void sagaCancel(WalletPayRequestVO param) { 33 | wlletService.doCancelPay(param); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-point-service/src/main/java/com/yiqiniu/easytrans/demos/point/impl/OrderFinishedMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.point.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.demos.order.api.vo.OrderFinishedMessage; 8 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 9 | import com.yiqiniu.easytrans.protocol.msg.ReliableMessageHandler; 10 | import com.yiqiniu.easytrans.queue.consumer.EasyTransConsumeAction; 11 | 12 | @Component 13 | public class OrderFinishedMessageHandler implements ReliableMessageHandler{ 14 | 15 | 16 | @Resource 17 | private PointService pointService; 18 | 19 | 20 | @Override 21 | public int getIdempotentType() { 22 | return IDENPOTENT_TYPE_FRAMEWORK; 23 | } 24 | 25 | @Override 26 | public EasyTransConsumeAction consume(EasyTransRequest request) { 27 | pointService.addPointForBuying((OrderFinishedMessage) request); 28 | return EasyTransConsumeAction.CommitMessage; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /easytrans-log-database-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | EasyTransaction transaction log RDBS implement 4 | 5 | easytrans-log-database-starter 6 | 7 | 8 | com.yiqiniu.easytrans 9 | easytrans 10 | ${revision} 11 | ../pom.xml 12 | 13 | 14 | 15 | UTF-8 16 | 17 | 18 | 19 | 20 | com.yiqiniu.easytrans 21 | easytrans-core 22 | 23 | 24 | 25 | com.alibaba 26 | druid 27 | 1.1.13 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-api/src/main/java/com/yiqiniu/easytrans/demos/wallet/api/vo/WalletPayVO.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.api.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.yiqiniu.easytrans.demos.wallet.api.WalletServiceApiConstant; 6 | import com.yiqiniu.easytrans.protocol.BusinessIdentifer; 7 | import com.yiqiniu.easytrans.protocol.saga.SagaTccMethodRequest; 8 | 9 | public class WalletPayVO { 10 | 11 | @BusinessIdentifer(appId=WalletServiceApiConstant.APPID,busCode="sagaPay") 12 | public static class WalletPayRequestVO implements Serializable,SagaTccMethodRequest { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | 17 | private Integer userId; 18 | 19 | private Long payAmount; 20 | 21 | public Long getPayAmount() { 22 | return payAmount; 23 | } 24 | 25 | public void setPayAmount(Long payAmount) { 26 | this.payAmount = payAmount; 27 | } 28 | 29 | public Integer getUserId() { 30 | return userId; 31 | } 32 | 33 | public void setUserId(Integer userId) { 34 | this.userId = userId; 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /easytrans-log-redis-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | EasyTransaction transaction log Redis implement 6 | 7 | easytrans-log-redis-starter 8 | 9 | 10 | com.yiqiniu.easytrans 11 | easytrans 12 | ${revision} 13 | ../pom.xml 14 | 15 | 16 | 17 | UTF-8 18 | 19 | 20 | 21 | 22 | 23 | biz.paluch.redis 24 | lettuce 25 | 4.4.5.Final 26 | 27 | 28 | 29 | 30 | com.yiqiniu.easytrans 31 | easytrans-core 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/util/FutureAdapter.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.util; 2 | 3 | import java.util.concurrent.ExecutionException; 4 | import java.util.concurrent.Future; 5 | import java.util.concurrent.TimeUnit; 6 | import java.util.concurrent.TimeoutException; 7 | 8 | public class FutureAdapter implements Future { 9 | 10 | @Override 11 | public boolean cancel(boolean mayInterruptIfRunning) { 12 | throw new RuntimeException("Not support Opeartion"); 13 | } 14 | 15 | @Override 16 | public boolean isCancelled() { 17 | throw new RuntimeException("Not support Opeartion"); 18 | } 19 | 20 | @Override 21 | public boolean isDone() { 22 | throw new RuntimeException("Not support Opeartion"); 23 | } 24 | 25 | @Override 26 | public R get() throws InterruptedException, ExecutionException { 27 | throw new RuntimeException("Not support Opeartion"); 28 | } 29 | 30 | @Override 31 | public R get(long timeout, TimeUnit unit) 32 | throws InterruptedException, ExecutionException, 33 | TimeoutException { 34 | throw new RuntimeException("Not support Opeartion"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-order-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: order-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/order?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8080 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | redis: 35 | enabled: true 36 | keyPrefix: "et:" 37 | redisUri: redis://localhost/ # 具体格式请参考 https://lettuce.io/core/release/reference/#redisuri.uri-syntax 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /easytrans-queue-ons-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | EasyTransaction queue alibaba ONS implement 4 | 5 | easytrans-queue-ons-starter 6 | 7 | 8 | com.yiqiniu.easytrans 9 | easytrans 10 | ${revision} 11 | ../pom.xml 12 | 13 | 14 | 15 | UTF-8 16 | 17 | 18 | 19 | 20 | com.yiqiniu.easytrans 21 | easytrans-core 22 | 23 | 24 | 25 | com.aliyun.openservices 26 | ons-client 27 | 28 | 1.7.0.Final 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-wallet-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: order-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/wallet?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8081 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | redis: 35 | enabled: true 36 | keyPrefix: "et:" 37 | redisUri: redis://localhost/ # 具体格式请参考 https://lettuce.io/core/release/reference/#redisuri.uri-syntax 38 | 39 | 40 | 41 | debug: true 42 | 43 | 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **settings** 27 | which type of idempotent support you use?(framework idempotent/business idempotent?) 28 | 29 | which version and component do you use( redis/rdb log implement and redis/rdb version? kafka/ons queue implements and queue version? ribbon/dubbo rpc implements?) 30 | 31 | **the relative records ** 32 | records in table executed_trans, idempotent, logs(trans_log_detail, trans_log_unfinished,or redis records) 33 | 34 | **can you reproduce it in demos by changing certain settings** 35 | this will help us understand the situation more effectively 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | sagatcc-wallet-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | sagatcc 13 | ${revision} 14 | 15 | 16 | 17 | UTF-8 18 | 1.8 19 | 20 | 21 | 22 | 23 | com.yiqiniu.easytrans 24 | easytrans-core 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-compiler-plugin 33 | 34 | 1.8 35 | 1.8 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-order-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | tccandmsg-order-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | tccandmsg 13 | ${revision} 14 | 15 | 16 | 17 | UTF-8 18 | 1.8 19 | 20 | 21 | 22 | 23 | com.yiqiniu.easytrans 24 | easytrans-core 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-compiler-plugin 33 | 34 | 1.8 35 | 1.8 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-wallet-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | tccandmsg-wallet-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | tccandmsg 13 | ${revision} 14 | 15 | 16 | 17 | UTF-8 18 | 1.8 19 | 20 | 21 | 22 | 23 | com.yiqiniu.easytrans 24 | easytrans-core 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-compiler-plugin 33 | 34 | 1.8 35 | 1.8 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /easytrans-log-database-starter/src/main/java/com/yiqiniu/easytrans/log/impl/database/DataBaseTransactionLogDetail.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.log.impl.database; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | public class DataBaseTransactionLogDetail implements Serializable { 7 | /** 8 | * 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | 12 | private Integer logDetailId; 13 | private byte[] transLogId; 14 | private byte[] logDetail; 15 | private Date createTime; 16 | 17 | public Integer getLogDetailId() { 18 | return logDetailId; 19 | } 20 | public void setLogDetailId(Integer logDetailId) { 21 | this.logDetailId = logDetailId; 22 | } 23 | 24 | public byte[] getTransLogId() { 25 | return transLogId; 26 | } 27 | public void setTransLogId(byte[] transLogId) { 28 | this.transLogId = transLogId; 29 | } 30 | public byte[] getLogDetail() { 31 | return logDetail; 32 | } 33 | 34 | public void setLogDetail(byte[] logDetail) { 35 | this.logDetail = logDetail; 36 | } 37 | 38 | public Date getCreateTime() { 39 | return createTime; 40 | } 41 | public void setCreateTime(Date createTime) { 42 | this.createTime = createTime; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/mockservice/notification/easytrans/NotificationConsumer.java: -------------------------------------------------------------------------------- 1 | //package com.yiqiniu.easytrans.test.mockservice.notification.easytrans; 2 | // 3 | //import javax.annotation.Resource; 4 | // 5 | //import org.springframework.stereotype.Component; 6 | // 7 | //import com.yiqiniu.easytrans.protocol.EasyTransRequest; 8 | //import com.yiqiniu.easytrans.protocol.msg.BestEffortMessageHandler; 9 | //import com.yiqiniu.easytrans.queue.consumer.EasyTransConsumeAction; 10 | //import com.yiqiniu.easytrans.test.mockservice.notification.NotificationService; 11 | //import com.yiqiniu.easytrans.test.mockservice.order.NotReliableOrderMessage; 12 | // 13 | //@Component 14 | //public class NotificationConsumer implements BestEffortMessageHandler { 15 | // 16 | // @Resource 17 | // private NotificationService service; 18 | // 19 | // @Override 20 | // public EasyTransConsumeAction consume(EasyTransRequest request) { 21 | // service.sendMsg((NotReliableOrderMessage) request); 22 | // return EasyTransConsumeAction.CommitMessage; 23 | // } 24 | // 25 | // @Override 26 | // public int getIdempotentType() { 27 | // return IDENPOTENT_TYPE_BUSINESS; 28 | // } 29 | // 30 | //} 31 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-wallet-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | interfacecall-wallet-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | interfacecall 13 | ${revision} 14 | 15 | 16 | 17 | UTF-8 18 | 1.8 19 | 20 | 21 | 22 | 23 | com.yiqiniu.easytrans 24 | easytrans-core 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-compiler-plugin 33 | 34 | 1.8 35 | 1.8 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-order-service/src/main/java/com/yiqiniu/easytrans/demos/order/impl/OrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.order.impl; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.transaction.annotation.EnableTransactionManagement; 7 | 8 | import com.yiqiniu.easytrans.EnableEasyTransaction; 9 | import com.yiqiniu.easytrans.demos.wallet.api.WalletPayMoneyService; 10 | import com.yiqiniu.easytrans.demos.wallet.api.requestcfg.WalletPayRequestCfg; 11 | import com.yiqiniu.easytrans.util.CallWrapUtil; 12 | 13 | @SpringBootApplication 14 | @EnableEasyTransaction 15 | @EnableTransactionManagement 16 | public class OrderApplication { 17 | public static void main(String[] args) { 18 | SpringApplication.run(OrderApplication.class, args); 19 | } 20 | 21 | /** 22 | * create WalletPayMoneyService instance, you can inject the instance to call wallet tcc service 23 | */ 24 | @Bean 25 | public WalletPayMoneyService payService(CallWrapUtil util) { 26 | return util.createTransactionCallInstance(WalletPayMoneyService.class, WalletPayRequestCfg.class); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-wallet-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | tcconly-wallet-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | tcconly 13 | ${revision} 14 | ../pom.xml 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | com.yiqiniu.easytrans 25 | easytrans-core 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-compiler-plugin 34 | 35 | 1.8 36 | 1.8 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/EtReliableMsg.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import com.yiqiniu.easytrans.protocol.AnnotationBusinessProviderBuilder.NullEasyTransRequest; 10 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 11 | 12 | /** 13 | * place in method of the bean that managed by spring 14 | * this method will do the TCC try 15 | * confirmMethod and cancelMethod should in the same class 16 | * @author xudeyou 17 | * 18 | */ 19 | @Target(ElementType.METHOD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @SuppressWarnings("rawtypes") 23 | public @interface EtReliableMsg { 24 | 25 | /** 26 | * BusinessProvider.IDENPOTENT_TYPE_FRAMEWORK 27 | * BusinessProvider.IDENPOTENT_TYPE_BUSINESS 28 | * @return 29 | */ 30 | int idempotentType(); 31 | 32 | 33 | /** 34 | * 当标注的方法的入参并非继承自EasyTransRequest时,需要用本字段指定继承自该类的类 35 | * @return 36 | */ 37 | Class cfgClass() default NullEasyTransRequest.class; 38 | } 39 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-wallet-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | logredis-wallet-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | logredis 13 | ${revision} 14 | ../pom.xml 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | com.yiqiniu.easytrans 25 | easytrans-core 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-compiler-plugin 34 | 35 | 1.8 36 | 1.8 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletPayTccService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayRequestVO; 8 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayResponseVO; 9 | import com.yiqiniu.easytrans.protocol.tcc.TccMethod; 10 | 11 | @Component 12 | public class WalletPayTccService implements TccMethod{ 13 | 14 | public static final String METHOD_NAME="pay"; 15 | 16 | @Resource 17 | private WalletService wlletService; 18 | 19 | @Override 20 | public WalletPayResponseVO doTry(WalletPayRequestVO param) { 21 | return wlletService.doTryPay(param); 22 | } 23 | 24 | @Override 25 | public void doConfirm(WalletPayRequestVO param) { 26 | wlletService.doConfirmPay(param); 27 | } 28 | 29 | 30 | @Override 31 | public void doCancel(WalletPayRequestVO param) { 32 | wlletService.doCancelPay(param); 33 | } 34 | 35 | 36 | @Override 37 | public int getIdempotentType() { 38 | return IDENPOTENT_TYPE_FRAMEWORK; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-wallet-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | rpcdubbo-wallet-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | rpcdubbo 13 | ${revision} 14 | ../pom.xml 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | com.yiqiniu.easytrans 25 | easytrans-core 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-compiler-plugin 34 | 35 | 1.8 36 | 1.8 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletPayTccService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayRequestVO; 8 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayResponseVO; 9 | import com.yiqiniu.easytrans.protocol.tcc.TccMethod; 10 | 11 | @Component 12 | public class WalletPayTccService implements TccMethod{ 13 | 14 | public static final String METHOD_NAME="pay"; 15 | 16 | @Resource 17 | private WalletService wlletService; 18 | 19 | @Override 20 | public WalletPayResponseVO doTry(WalletPayRequestVO param) { 21 | return wlletService.doTryPay(param); 22 | } 23 | 24 | @Override 25 | public void doConfirm(WalletPayRequestVO param) { 26 | wlletService.doConfirmPay(param); 27 | } 28 | 29 | 30 | @Override 31 | public void doCancel(WalletPayRequestVO param) { 32 | wlletService.doCancelPay(param); 33 | } 34 | 35 | 36 | @Override 37 | public int getIdempotentType() { 38 | return IDENPOTENT_TYPE_FRAMEWORK; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletPayTccService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayRequestVO; 8 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayResponseVO; 9 | import com.yiqiniu.easytrans.protocol.tcc.TccMethod; 10 | 11 | @Component 12 | public class WalletPayTccService implements TccMethod{ 13 | 14 | public static final String METHOD_NAME="pay"; 15 | 16 | @Resource 17 | private WalletService wlletService; 18 | 19 | @Override 20 | public WalletPayResponseVO doTry(WalletPayRequestVO param) { 21 | return wlletService.doTryPay(param); 22 | } 23 | 24 | @Override 25 | public void doConfirm(WalletPayRequestVO param) { 26 | wlletService.doConfirmPay(param); 27 | } 28 | 29 | 30 | @Override 31 | public void doCancel(WalletPayRequestVO param) { 32 | wlletService.doCancelPay(param); 33 | } 34 | 35 | 36 | @Override 37 | public int getIdempotentType() { 38 | return IDENPOTENT_TYPE_FRAMEWORK; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/ExecuteOrder.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol; 2 | 3 | import static java.lang.annotation.ElementType.METHOD; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * define the execute order of methods 11 | */ 12 | @Target({METHOD}) 13 | @Retention(RUNTIME) 14 | public @interface ExecuteOrder { 15 | 16 | /** 17 | * do not execute method after one of the methods in the list called 18 | * typical used in TCC, if cancel-method executed,then latter try-method should not be execute 19 | */ 20 | String[] doNotExecuteAfter(); 21 | 22 | /** 23 | * if the one of the methods executed,then return directly without execute business implement
24 | * typical used in CompensableBusiness, if doCompensableBusiness did not work,
25 | * then call doCompensation should not execute business codes,just return directly 26 | */ 27 | String[] ifNotExecutedReturnDirectly(); 28 | 29 | /** 30 | * whether is the synchronizer method for business
31 | * For example,TCC's Try method is synchronizer method 32 | */ 33 | boolean isSynchronousMethod() default false; 34 | } 35 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/autocps/EtAutoCps.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.autocps; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import com.yiqiniu.easytrans.protocol.AnnotationBusinessProviderBuilder.NullEasyTransRequest; 10 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 11 | 12 | /** 13 | * place in method of the bean that managed by spring 14 | * this method will do the TCC try 15 | * confirmMethod and cancelMethod should in the same class 16 | * @author xudeyou 17 | * 18 | */ 19 | @Target(ElementType.METHOD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @SuppressWarnings("rawtypes") 23 | public @interface EtAutoCps { 24 | /** 25 | * BusinessProvider.IDENPOTENT_TYPE_FRAMEWORK 26 | * BusinessProvider.IDENPOTENT_TYPE_BUSINESS 27 | * @return 28 | */ 29 | int idempotentType(); 30 | 31 | 32 | /** 33 | * 当标注的方法的入参并非继承自EasyTransRequest时,需要用本字段指定继承自该类的类 34 | * @return 35 | */ 36 | Class cfgClass() default NullEasyTransRequest.class; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletPayTccService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayRequestVO; 8 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayResponseVO; 9 | import com.yiqiniu.easytrans.protocol.tcc.TccMethod; 10 | 11 | @Component 12 | public class WalletPayTccService implements TccMethod{ 13 | 14 | public static final String METHOD_NAME="pay"; 15 | 16 | @Resource 17 | private WalletService wlletService; 18 | 19 | @Override 20 | public WalletPayResponseVO doTry(WalletPayRequestVO param) { 21 | return wlletService.doTryPay(param); 22 | } 23 | 24 | @Override 25 | public void doConfirm(WalletPayRequestVO param) { 26 | wlletService.doConfirmPay(param); 27 | } 28 | 29 | 30 | @Override 31 | public void doCancel(WalletPayRequestVO param) { 32 | wlletService.doCancelPay(param); 33 | } 34 | 35 | 36 | @Override 37 | public int getIdempotentType() { 38 | return IDENPOTENT_TYPE_FRAMEWORK; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-rpc-rest-ribbon-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | EasyTransaction RPC netflix ribbon rest implement 4 | 5 | easytrans-rpc-rest-ribbon-starter 6 | 7 | 8 | com.yiqiniu.easytrans 9 | easytrans 10 | ${revision} 11 | ../pom.xml 12 | 13 | 14 | 15 | UTF-8 16 | 17 | 18 | 19 | 20 | com.yiqiniu.easytrans 21 | easytrans-core 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | 30 | org.springframework.cloud 31 | spring-cloud-starter-ribbon 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-wallet-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/WalletPayTccService.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayRequestVO; 8 | import com.yiqiniu.easytrans.demos.wallet.api.vo.WalletPayVO.WalletPayResponseVO; 9 | import com.yiqiniu.easytrans.protocol.tcc.TccMethod; 10 | 11 | @Component 12 | public class WalletPayTccService implements TccMethod{ 13 | 14 | public static final String METHOD_NAME="pay"; 15 | 16 | @Resource 17 | private WalletService wlletService; 18 | 19 | @Override 20 | public WalletPayResponseVO doTry(WalletPayRequestVO param) { 21 | return wlletService.doTryPay(param); 22 | } 23 | 24 | @Override 25 | public void doConfirm(WalletPayRequestVO param) { 26 | wlletService.doConfirmPay(param); 27 | } 28 | 29 | 30 | @Override 31 | public void doCancel(WalletPayRequestVO param) { 32 | wlletService.doCancelPay(param); 33 | } 34 | 35 | 36 | @Override 37 | public int getIdempotentType() { 38 | return IDENPOTENT_TYPE_FRAMEWORK; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/mockservice/point/easytrans/PointOrderSuccessConsumer.java: -------------------------------------------------------------------------------- 1 | //package com.yiqiniu.easytrans.test.mockservice.point.easytrans; 2 | // 3 | //import javax.annotation.Resource; 4 | // 5 | //import org.springframework.stereotype.Component; 6 | // 7 | //import com.yiqiniu.easytrans.protocol.EasyTransRequest; 8 | //import com.yiqiniu.easytrans.protocol.msg.ReliableMessageHandler; 9 | //import com.yiqiniu.easytrans.queue.consumer.EasyTransConsumeAction; 10 | //import com.yiqiniu.easytrans.test.mockservice.order.OrderMessage; 11 | //import com.yiqiniu.easytrans.test.mockservice.point.PointService; 12 | // 13 | //@Component 14 | //public class PointOrderSuccessConsumer implements ReliableMessageHandler { 15 | // 16 | // @Resource 17 | // private PointService pointService; 18 | // 19 | // 20 | // 21 | // @Override 22 | // public EasyTransConsumeAction consume(EasyTransRequest request) { 23 | // 24 | // pointService.addPointForBuying((OrderMessage) request); 25 | // return EasyTransConsumeAction.CommitMessage; 26 | //// return EasyTransConsumeAction.ReconsumeLater; 27 | // } 28 | // 29 | // @Override 30 | // public int getIdempotentType() { 31 | // return IDENPOTENT_TYPE_FRAMEWORK; 32 | // } 33 | // 34 | //} 35 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/msg/EtBestEffortMsg.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.msg; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import com.yiqiniu.easytrans.protocol.AnnotationBusinessProviderBuilder.NullEasyTransRequest; 10 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 11 | 12 | /** 13 | * place in method of the bean that managed by spring 14 | * this method will do the TCC try 15 | * confirmMethod and cancelMethod should in the same class 16 | * @author xudeyou 17 | * 18 | */ 19 | @Target(ElementType.METHOD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @SuppressWarnings("rawtypes") 23 | public @interface EtBestEffortMsg { 24 | 25 | /** 26 | * BusinessProvider.IDENPOTENT_TYPE_FRAMEWORK 27 | * BusinessProvider.IDENPOTENT_TYPE_BUSINESS 28 | * @return 29 | */ 30 | int idempotentType(); 31 | 32 | 33 | /** 34 | * 当标注的方法的入参并非继承自EasyTransRequest时,需要用本字段指定继承自该类的类 35 | * @return 36 | */ 37 | Class cfgClass() default NullEasyTransRequest.class; 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-coupon-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | tccandfescar-coupon-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | tccandfescar 13 | ${revision} 14 | ../pom.xml 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | com.yiqiniu.easytrans 25 | easytrans-core 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-compiler-plugin 34 | 35 | 1.8 36 | 1.8 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-wallet-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | 8 | tccandfescar-wallet-api 9 | 10 | 11 | com.yiqiniu.easytrans.demos 12 | tccandfescar 13 | ${revision} 14 | ../pom.xml 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 21 | 22 | 23 | 24 | com.yiqiniu.easytrans 25 | easytrans-core 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-compiler-plugin 34 | 35 | 1.8 36 | 1.8 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/cps/EtCps.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.cps; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import com.yiqiniu.easytrans.protocol.AnnotationBusinessProviderBuilder.NullEasyTransRequest; 10 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 11 | 12 | /** 13 | * place in method of the bean that managed by spring 14 | * this method will do the TCC try 15 | * confirmMethod and cancelMethod should in the same class 16 | * @author xudeyou 17 | * 18 | */ 19 | @Target(ElementType.METHOD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @SuppressWarnings("rawtypes") 23 | public @interface EtCps { 24 | String cancelMethod(); 25 | 26 | /** 27 | * BusinessProvider.IDENPOTENT_TYPE_FRAMEWORK 28 | * BusinessProvider.IDENPOTENT_TYPE_BUSINESS 29 | * @return 30 | */ 31 | int idempotentType(); 32 | 33 | 34 | /** 35 | * 当标注的方法的入参并非继承自EasyTransRequest时,需要用本字段指定继承自该类的类 36 | * @return 37 | */ 38 | Class cfgClass() default NullEasyTransRequest.class; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-order-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: order-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/order?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8080 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/order_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-coupon-service/src/main/java/com/yiqiniu/easytrans/demos/wallet/impl/CouponApplication.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.demos.wallet.impl; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.transaction.annotation.EnableTransactionManagement; 9 | 10 | import com.alibaba.druid.pool.DruidDataSource; 11 | import com.yiqiniu.easytrans.EnableEasyTransaction; 12 | 13 | import io.seata.rm.datasource.DataSourceProxy; 14 | 15 | @SpringBootApplication 16 | @EnableEasyTransaction 17 | @EnableTransactionManagement 18 | public class CouponApplication { 19 | public static void main(String[] args) { 20 | SpringApplication.run(CouponApplication.class, args); 21 | } 22 | 23 | @Bean 24 | public DataSource dataSourceProxy() { 25 | 26 | DruidDataSource druidDataSource = new DruidDataSource(); 27 | druidDataSource.setUrl("jdbc:mysql://localhost:3306/coupon?characterEncoding=UTF-8&useSSL=false"); 28 | druidDataSource.setUsername("root"); 29 | druidDataSource.setPassword("123456"); 30 | 31 | return new DataSourceProxy(druidDataSource); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-order-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: order-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/order?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8080 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/order_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/java/com/yiqiniu/easytrans/test/mockservice/point/easytrans/PointOrderSuccessForCascadeTestConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.test.mockservice.point.easytrans; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 8 | import com.yiqiniu.easytrans.protocol.msg.ReliableMessageHandler; 9 | import com.yiqiniu.easytrans.queue.consumer.EasyTransConsumeAction; 10 | import com.yiqiniu.easytrans.test.mockservice.order.OrderMessageForCascadingTest; 11 | import com.yiqiniu.easytrans.test.mockservice.point.PointService; 12 | 13 | @Component 14 | public class PointOrderSuccessForCascadeTestConsumer implements ReliableMessageHandler { 15 | 16 | @Resource 17 | private PointService pointService; 18 | 19 | 20 | 21 | @Override 22 | public EasyTransConsumeAction consume(EasyTransRequest request) { 23 | 24 | pointService.addPointForBuyingCascading((OrderMessageForCascadingTest) request); 25 | return EasyTransConsumeAction.CommitMessage; 26 | // return EasyTransConsumeAction.ReconsumeLater; 27 | } 28 | 29 | @Override 30 | public int getIdempotentType() { 31 | return IDENPOTENT_TYPE_FRAMEWORK; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/aft/EtAfterMasterTrans.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.aft; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import com.yiqiniu.easytrans.protocol.AnnotationBusinessProviderBuilder.NullEasyTransRequest; 10 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 11 | 12 | /** 13 | * place in method of the bean that managed by spring 14 | * this method will do the TCC try 15 | * confirmMethod and cancelMethod should in the same class 16 | * @author xudeyou 17 | * 18 | */ 19 | @Target(ElementType.METHOD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @SuppressWarnings("rawtypes") 23 | public @interface EtAfterMasterTrans { 24 | 25 | /** 26 | * BusinessProvider.IDENPOTENT_TYPE_FRAMEWORK 27 | * BusinessProvider.IDENPOTENT_TYPE_BUSINESS 28 | * @return 29 | */ 30 | int idempotentType(); 31 | 32 | 33 | /** 34 | * 当标注的方法的入参并非继承自EasyTransRequest时,需要用本字段指定继承自该类的类 35 | * @return 36 | */ 37 | Class cfgClass() default NullEasyTransRequest.class; 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-order-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: order-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/order?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8080 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/order_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: wallet-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/wallet?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8081 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/wallet_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/stringcodec/impl/ZookeeperStringCodecConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.stringcodec.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 6 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import com.yiqiniu.easytrans.stringcodec.StringCodec; 11 | 12 | /** 13 | * @author xudeyou 14 | */ 15 | @Configuration 16 | @ConditionalOnProperty(name="easytrans.stringcodec.zk.enabled",havingValue="true",matchIfMissing=true) 17 | @EnableConfigurationProperties(ZookeeperStringCodecProperties.class) 18 | public class ZookeeperStringCodecConfiguration { 19 | 20 | @Value("${spring.application.name}") 21 | private String applicationName; 22 | 23 | @Bean 24 | @ConditionalOnMissingBean(StringCodec.class) 25 | public StringCodec zooKeeperStringCodecImpl(ZookeeperStringCodecProperties properties){ 26 | return new ZooKeeperStringCodecImpl(properties.getZooKeeperUrl(), applicationName); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-msg/tccandmsg-wallet-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: wallet-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/wallet?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8081 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/wallet_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /easytrans-dashboard/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=info,stdout,logfile,errfile 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 7 | #log4j.appender.stdout.Threshold = DEBUG 8 | 9 | log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.DatePattern='.'yyyy-MM-dd 11 | log4j.appender.logfile.File=logs/info.log 12 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 14 | 15 | log4j.appender.errfile=org.apache.log4j.RollingFileAppender 16 | log4j.appender.errfile.MaxFileSize=5000KB 17 | log4j.appender.errfile.MaxBackupIndex=3 18 | log4j.appender.errfile.File=logs/err.log 19 | log4j.appender.errfile.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.errfile.layout.ConversionPattern=%d %p [%c] - %m%n 21 | log4j.appender.errfile.Threshold = ERROR 22 | 23 | log4j.logger.org.apache.zookeeper=OFF 24 | log4j.logger.com.alibaba=OFF 25 | log4j.logger.druid.sql=OFF 26 | log4j.logger.org.springframework=OFF 27 | log4j.logger.com.yiqiniu.easytrans=ON 28 | log4j.logger.com.yiqiniu.easytrans.core=TRACE 29 | -------------------------------------------------------------------------------- /easytrans-demo/interface-call/interfacecall-wallet-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: wallet-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/wallet?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8081 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/wallet_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-wallet-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: order-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/wallet?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8081 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/wallet_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-only/tcconly-wallet-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: order-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | datasource: # order service datasource config 5 | url: jdbc:mysql://localhost:3306/wallet?characterEncoding=UTF-8&useSSL=false 6 | username: root 7 | password: 123456 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8081 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/wallet_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | debug: true 46 | 47 | 48 | -------------------------------------------------------------------------------- /easytrans-starter/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=info,stdout,logfile,errfile 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 7 | log4j.appender.stdout.Threshold = DEBUG 8 | 9 | log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.DatePattern='.'yyyy-MM-dd 11 | log4j.appender.logfile.File=logs/info.log 12 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 14 | 15 | log4j.appender.errfile=org.apache.log4j.RollingFileAppender 16 | log4j.appender.errfile.MaxFileSize=5000KB 17 | log4j.appender.errfile.MaxBackupIndex=3 18 | log4j.appender.errfile.File=logs/err.log 19 | log4j.appender.errfile.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.errfile.layout.ConversionPattern=%d %p [%c] - %m%n 21 | log4j.appender.errfile.Threshold = ERROR 22 | 23 | log4j.logger.org.apache.zookeeper=OFF 24 | log4j.logger.com.alibaba=OFF 25 | log4j.logger.druid.sql=OFF 26 | log4j.logger.org.springframework=DEBUG 27 | log4j.logger.com.yiqiniu.easytrans=DEBUG 28 | log4j.logger.com.yiqiniu.easytrans.core=DEBUG 29 | -------------------------------------------------------------------------------- /easytrans-demo/tcc-and-fescar/tccandfescar-coupon-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: coupon-service # the same with com.yiqiniu.easytrans.demos.order.Constant.APPID 4 | # datasource: # order service datasource config 5 | # url: jdbc:mysql://localhost:3306/coupon?characterEncoding=UTF-8&useSSL=false 6 | # username: root 7 | # password: 123456 8 | # driver-class-name: com.mysql.jdbc.Driver 9 | 10 | server: 11 | port: 8082 12 | 13 | # RIBBON用,也可以直接开启Eureka 14 | order-service: 15 | ribbon: 16 | listOfServers: localhost:8080 17 | 18 | wallet-service: 19 | ribbon: 20 | listOfServers: localhost:8081 21 | 22 | easytrans: 23 | master: 24 | zk: 25 | zooKeeperUrl: localhost:2281 26 | stringcodec: 27 | zk: 28 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 29 | idgen: 30 | trxId: 31 | zkSnow: 32 | zooKeeperUrl: ${easytrans.master.zk.zooKeeperUrl} 33 | log: 34 | database: 35 | logCleanEnabled: true 36 | logReservedDays: 14 37 | logCleanTime: 01:22:00 38 | druid: 39 | driverClassName: com.mysql.jdbc.Driver 40 | url: jdbc:mysql://localhost:3306/coupon_translog?characterEncoding=UTF-8&useSSL=false 41 | username: root 42 | password: 123456 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /easytrans-queue-ons-starter/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=info,stdout,logfile,errfile 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 7 | #log4j.appender.stdout.Threshold = DEBUG 8 | 9 | log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.DatePattern='.'yyyy-MM-dd 11 | log4j.appender.logfile.File=logs/info.log 12 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 14 | 15 | log4j.appender.errfile=org.apache.log4j.RollingFileAppender 16 | log4j.appender.errfile.MaxFileSize=5000KB 17 | log4j.appender.errfile.MaxBackupIndex=3 18 | log4j.appender.errfile.File=logs/err.log 19 | log4j.appender.errfile.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.errfile.layout.ConversionPattern=%d %p [%c] - %m%n 21 | log4j.appender.errfile.Threshold = ERROR 22 | 23 | log4j.logger.org.apache.zookeeper=OFF 24 | log4j.logger.com.alibaba=OFF 25 | log4j.logger.druid.sql=OFF 26 | log4j.logger.org.springframework=OFF 27 | log4j.logger.com.yiqiniu.easytrans=ON 28 | log4j.logger.com.yiqiniu.easytrans.core=TRACE 29 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/protocol/tcc/EtTcc.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.protocol.tcc; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import com.yiqiniu.easytrans.protocol.AnnotationBusinessProviderBuilder.NullEasyTransRequest; 10 | import com.yiqiniu.easytrans.protocol.EasyTransRequest; 11 | 12 | /** 13 | * place in method of the bean that managed by spring 14 | * this method will do the TCC try 15 | * confirmMethod and cancelMethod should in the same class 16 | * @author xudeyou 17 | * 18 | */ 19 | @Target(ElementType.METHOD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @SuppressWarnings("rawtypes") 23 | public @interface EtTcc { 24 | String confirmMethod(); 25 | String cancelMethod(); 26 | 27 | /** 28 | * BusinessProvider.IDENPOTENT_TYPE_FRAMEWORK 29 | * BusinessProvider.IDENPOTENT_TYPE_BUSINESS 30 | * @return 31 | */ 32 | int idempotentType(); 33 | 34 | 35 | /** 36 | * 当标注的方法的入参并非继承自EasyTransRequest时,需要用本字段指定继承自该类的类 37 | * @return 38 | */ 39 | Class cfgClass() default NullEasyTransRequest.class; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /easytrans-core/src/main/java/com/yiqiniu/easytrans/master/impl/ZookeeperMasterSelectorConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.yiqiniu.easytrans.master.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 6 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import com.yiqiniu.easytrans.master.EasyTransMasterSelector; 11 | 12 | /** 13 | * @author xudeyou 14 | */ 15 | @Configuration 16 | @ConditionalOnProperty(name="easytrans.master.zk.enabled",havingValue="true",matchIfMissing=true) 17 | @EnableConfigurationProperties(ZookeeperMasterSelectorProperties.class) 18 | public class ZookeeperMasterSelectorConfiguration { 19 | 20 | @Value("${spring.application.name}") 21 | private String applicationName; 22 | 23 | @Bean 24 | @ConditionalOnMissingBean(EasyTransMasterSelector.class) 25 | public EasyTransMasterSelector zooKeeperMasterSelectorImpl(ZookeeperMasterSelectorProperties properties){ 26 | return new ZooKeeperMasterSelectorImpl(properties.getZooKeeperUrl(), applicationName); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /easytrans-demo/log-redis/logredis-order-service/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=info,stdout,logfile,errfile 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 7 | #log4j.appender.stdout.Threshold = DEBUG 8 | 9 | log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.DatePattern='.'yyyy-MM-dd 11 | log4j.appender.logfile.File=logs/info.log 12 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 14 | 15 | log4j.appender.errfile=org.apache.log4j.RollingFileAppender 16 | log4j.appender.errfile.MaxFileSize=5000KB 17 | log4j.appender.errfile.MaxBackupIndex=3 18 | log4j.appender.errfile.File=logs/err.log 19 | log4j.appender.errfile.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.errfile.layout.ConversionPattern=%d %p [%c] - %m%n 21 | log4j.appender.errfile.Threshold = ERROR 22 | 23 | log4j.logger.org.apache.zookeeper=OFF 24 | log4j.logger.com.alibaba=OFF 25 | log4j.logger.druid.sql=OFF 26 | log4j.logger.org.springframework=OFF 27 | log4j.logger.com.yiqiniu.easytrans=ON 28 | log4j.logger.com.yiqiniu.easytrans.core=TRACE 29 | -------------------------------------------------------------------------------- /easytrans-demo/rpc-dubbo/rpcdubbo-order-service/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=info,stdout,logfile,errfile 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 7 | #log4j.appender.stdout.Threshold = DEBUG 8 | 9 | log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.DatePattern='.'yyyy-MM-dd 11 | log4j.appender.logfile.File=logs/info.log 12 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 14 | 15 | log4j.appender.errfile=org.apache.log4j.RollingFileAppender 16 | log4j.appender.errfile.MaxFileSize=5000KB 17 | log4j.appender.errfile.MaxBackupIndex=3 18 | log4j.appender.errfile.File=logs/err.log 19 | log4j.appender.errfile.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.errfile.layout.ConversionPattern=%d %p [%c] - %m%n 21 | log4j.appender.errfile.Threshold = ERROR 22 | 23 | log4j.logger.org.apache.zookeeper=OFF 24 | log4j.logger.com.alibaba=OFF 25 | log4j.logger.druid.sql=OFF 26 | log4j.logger.org.springframework=OFF 27 | log4j.logger.com.yiqiniu.easytrans=ON 28 | log4j.logger.com.yiqiniu.easytrans.core=TRACE 29 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-order-service/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=info,stdout,logfile,errfile 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 7 | #log4j.appender.stdout.Threshold = DEBUG 8 | 9 | log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.DatePattern='.'yyyy-MM-dd 11 | log4j.appender.logfile.File=logs/info.log 12 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 14 | 15 | log4j.appender.errfile=org.apache.log4j.RollingFileAppender 16 | log4j.appender.errfile.MaxFileSize=5000KB 17 | log4j.appender.errfile.MaxBackupIndex=3 18 | log4j.appender.errfile.File=logs/err.log 19 | log4j.appender.errfile.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.errfile.layout.ConversionPattern=%d %p [%c] - %m%n 21 | log4j.appender.errfile.Threshold = ERROR 22 | 23 | log4j.logger.org.apache.zookeeper=OFF 24 | log4j.logger.com.alibaba=OFF 25 | log4j.logger.druid.sql=OFF 26 | log4j.logger.org.springframework=OFF 27 | log4j.logger.com.yiqiniu.easytrans=ON 28 | log4j.logger.com.yiqiniu.easytrans.core=TRACE 29 | -------------------------------------------------------------------------------- /easytrans-demo/sagatcc/sagatcc-wallet-service/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=info,stdout,logfile,errfile 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 7 | #log4j.appender.stdout.Threshold = DEBUG 8 | 9 | log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.DatePattern='.'yyyy-MM-dd 11 | log4j.appender.logfile.File=logs/info.log 12 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 14 | 15 | log4j.appender.errfile=org.apache.log4j.RollingFileAppender 16 | log4j.appender.errfile.MaxFileSize=5000KB 17 | log4j.appender.errfile.MaxBackupIndex=3 18 | log4j.appender.errfile.File=logs/err.log 19 | log4j.appender.errfile.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.errfile.layout.ConversionPattern=%d %p [%c] - %m%n 21 | log4j.appender.errfile.Threshold = ERROR 22 | 23 | log4j.logger.org.apache.zookeeper=OFF 24 | log4j.logger.com.alibaba=OFF 25 | log4j.logger.druid.sql=OFF 26 | log4j.logger.org.springframework=OFF 27 | log4j.logger.com.yiqiniu.easytrans=ON 28 | log4j.logger.com.yiqiniu.easytrans.core=TRACE 29 | --------------------------------------------------------------------------------