-
Notifications
You must be signed in to change notification settings - Fork 1
Developer Documentation
You may use spring-cloud, dubbo, etc. or need customization, such as transaction storage, transaction realtime, etc. easytcc considers extension and custom plug-in.
你可能在使用spring-cloud,dubbo等或者需要自定义,例如事务存储、事务实时方式等,easytcc考虑了扩展和自定义插拔
default store is redis
You can customize RedisResource implementation as redis resource pool and configure JDK SPI that is META-INF/services/github.easytcc.repository.redis.RedisResource
可以自定义 RedisResource 实现作为redis的资源池,配置JDK SPI 即META-INF/services/github.easytcc.repository.redis.RedisResource
You can customize LockRepository,XidRepository,LocalTransactionRepository,TransactionDownstreamRepository,MetricsRepository and configure JDK SPI
可以自定义 LockRepository,XidRepository,LocalTransactionRepository,TransactionDownstreamRepository,MetricsRepository 实现,配置JDK SPI
default remoting is netty
TransactionChannel is used for realtime transaction commit/rollback
You can customize TransactionChannel and configure JDK SPI
If you need to deal with anything at the transaction annotation pointcut, you can customize the Transaction Aspect Interceptor reality in the spring bean way
如果需要在事务注解切点处理些什么,可以以spring bean方式自定义TransactionAspectInterceptor现实
@Bean
public TransactionAspectInterceptor yourInterceptor() {
...
}
It has the following interfaces:
void preHandle(ProceedingJoinPointWrapper pointWrapper,ExecutionChain chain) throws Exception;
void postHandle(ProceedingJoinPointWrapper pointWrapper);
void afterCompletion(ProceedingJoinPointWrapper pointWrapper, Throwable e);
You can use feign Request Interceptor to handle transaction context delivery
使用 feign RequestInterceptor 处理事务上下文传递
because of hystrix use threadpool , transaction context should pass between threads,There is already a built-in and available github.easytcc.hystrix.ContextHystrixConcurrencyStrategy 因为hystrix使用线程池,事务上下文需要在线程间正确传递,这里有内置可用的 github.easytcc.hystrix.ContextHystrixConcurrencyStrategy
<dependency>
<groupId>github.easytcc</groupId>
<artifactId>easytcc-hystrix</artifactId>
<version>${easytcc.version}</version>
</dependency>
Of course, you can customize Hystrix Concurrent Strategy without using this built-in
当然你可以不使用这个内置,自定义HystrixConcurrencyStrategy
then register the impl of HystrixConcurrencyStrategy
HystrixPlugins.getInstance().registerConcurrencyStrategy...
Next, you can get the required context in the hystrix thread and set the request.
接下来就可以在hystrix的线程中获取需要的上下文进行请求设置
ContextHeaders headers = ContextHeaders.get();
while (headers.hasNext()) {
KeyValuePair pair = headers.next();
httpHeaders.add(pair.getKey(), pair.getValue());
}
note:Hystrix only allows one Hystrix Concurrent Strategy to exist, and you may need to wrap it.
注意:hystrix只允许有一个HystrixConcurrencyStrategy存在,你可能需要包装
For example, with dubbo, you need to ensure that the transaction context is passed, set the context at the time of invocation, acquire and build the context at the receiving end,see github.easytcc.support.ContextHeaders
例如使用dubbo,需要确保事务上下文传递,在调用时设置上下文,在接收端获取并构建上下文,参考github.easytcc.support.ContextHeaders