kpioneer123 commented on issue #7380:
URL: https://github.com/apache/shardingsphere/issues/7380#issuecomment-690839961


   > can you try a case without your fix?
   
   yes,I try this case by hard-coded in SeataATShardingTransactionManager
   
       public SeataATShardingTransactionManager() {
           FileConfiguration configuration = new 
FileConfiguration("seata.conf");
           enableSeataAT = true;
           applicationId = "account-service";
           transactionServiceGroup = "my_test_tx_group";
       }
   
   **but  1.sharding is ERROR (though can curd,but Scan all db and table, 
Obviously it will time out)
              2.seata TransactionManager can‘t  rollback 
   this my sharding config**
   
   ```
   
   @Bean("bookPunchDataSource")
       public DataSource dataSource() throws SQLException {
   
           // 打开shardingsphere sql日志
           Properties properties = new Properties();
           properties.setProperty("sql.show", Boolean.TRUE.toString());
   
           // 配置分片规则
           ShardingRuleConfiguration shardingRuleConfig = new 
ShardingRuleConfiguration();
           TableRuleConfiguration bookTableRuleConfig = new 
TableRuleConfiguration(TABLE_NAME, "sharding_${0.." + (DB_SIZE - 1) + 
"}."+TABLE_NAME+"_${0..99}");
           bookTableRuleConfig.setDatabaseShardingStrategyConfig(new 
InlineShardingStrategyConfiguration("user_id", "sharding_${user_id % " + 
DB_SIZE + "}"));
           bookTableRuleConfig.setTableShardingStrategyConfig(new 
InlineShardingStrategyConfiguration("user_id", 
TABLE_NAME+"_${(Integer)(user_id/" + DB_SIZE + ") % 100}"));
   //        
bookTableRuleConfig.setKeyGeneratorConfig(keyGeneratorConfiguration());
           shardingRuleConfig.getTableRuleConfigs().add(bookTableRuleConfig);
   
   
           // 获取数据源对象
           DataSource dataSource = 
ShardingDataSourceFactory.createDataSource(createDataSourceMap(), 
shardingRuleConfig, properties);
           return dataSource;
       }
   
       @Bean
       public DataSourceTransactionManager 
shardTransactionManager(@Qualifier("bookPunchDataSource") DataSource 
dataSource) {
           return new DataSourceTransactionManager(dataSource);
       }
   
       @Bean("bookPunchSqlSessionFactory")
       public SqlSessionFactory 
sqlSessionFactory(@Qualifier("bookPunchDataSource") DataSource dataSource) 
throws Exception {
           SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
           bean.setDataSource(dataSource);
           bean.setMapperLocations(new 
PathMatchingResourcePatternResolver().getResources("classpath*:mapper/*.xml"));
           return bean.getObject();
       }
   
       @Bean("bookPunchSqlSessionTemplate")
       public SqlSessionTemplate 
sqlSessionTemplate(@Qualifier("bookPunchSqlSessionFactory") SqlSessionFactory 
sqlSessionFactory) throws Exception {
           return new SqlSessionTemplate(sqlSessionFactory);
       }
   
   
       private Map<String, DataSource> createDataSourceMap() {
           Map<String, DataSource> result = new HashMap<>();
           for (int i = 0; i < DB_SIZE; i++) {
               result.put("sharding_" + i, 
DataSourceUtil.createDataSource("sharding_" + i, host));
           }
           return result;
       }
   ```
   
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to