提交 2bdb6014 编写于 作者: C cherrylzhao

revise example for XA transaction.

上级 f186a0b8
......@@ -24,7 +24,7 @@ import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfigurati
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan({"io.shardingsphere.example.common.jpa", "io.shardingsphere.example.transaction.xa.spring.boot"})
@ComponentScan({"io.shardingsphere.example"})
@EntityScan(basePackages = "io.shardingsphere.example.common.jpa.entity")
@SpringBootApplication(exclude = JtaAutoConfiguration.class)
public class SpringBootExample {
......
......@@ -22,8 +22,6 @@ import io.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl;
import io.shardingsphere.example.common.jdbc.repository.OrderRepositoryImpl;
import io.shardingsphere.example.common.jdbc.service.CommonServiceImpl;
import io.shardingsphere.example.common.service.CommonService;
import io.shardingsphere.example.type.ShardingType;
import org.apache.shardingsphere.shardingjdbc.api.yaml.YamlMasterSlaveDataSourceFactory;
import org.apache.shardingsphere.shardingjdbc.api.yaml.YamlShardingDataSourceFactory;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
......@@ -46,7 +44,7 @@ public class YamlConfigurationTransactionExample {
DataSource dataSource = YamlShardingDataSourceFactory.createDataSource(getFile(configFile));
CommonService commonService = getCommonService(dataSource);
commonService.initEnvironment();
processBaseTransaction(dataSource, commonService);
processSagaTransaction(dataSource, commonService);
commonService.cleanEnvironment();
}
......@@ -58,7 +56,7 @@ public class YamlConfigurationTransactionExample {
return new CommonServiceImpl(new OrderRepositoryImpl(dataSource), new OrderItemRepositoryImpl(dataSource));
}
private static void processBaseTransaction(final DataSource dataSource, final CommonService commonService) throws SQLException {
private static void processSagaTransaction(final DataSource dataSource, final CommonService commonService) throws SQLException {
TransactionTypeHolder.set(TransactionType.BASE);
System.out.println("------ start succeed transaction ------");
try (Connection connection = dataSource.getConnection()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册