请查看以下查询.SQL没有它看起来那么糟糕.基本上,我们有一个事实表和一些简单的连接到一些维度表.然后我们有一个派生表的连接,给定别名ACCOUNTS-DIM-DEP
SELECT dw_mgr.fa_trans_fct.period,
dw_mgr.fa_trans_fct.asset_cost_company_code,
dw_mgr.fa_trans_fct.asset_cost_center_id,
dw_mgr.fa_trans_fct.depreciation_account_id,
accounts_dim_dep.description,
dw_mgr.projects_dim.project_num,
dw_mgr.projects_dim.project_name,
ROUND (dw_mgr.fa_trans_fct.activity_deprn_amount_us, 2),
organizations_cost.major_geography,
organizations_cost.business_unit || organizations_cost.bu_desc,
organizations_cost.industry_sector_num
||organizations_cost.industry_sector_desc,
hyperion_organizations.hyperion_num,
hyperion_organizations.hyperion_desc,
hyperion_organizations.hyperion_reporting
FROM dw_mgr.fa_trans_fct,
(SELECT DISTINCT flex_value account_id, description
FROM rf_fnd_flex_values_det
WHERE flex_value_set_id = '1002363'
AND summary_flag = 'N') accounts_dim_dep,
dw_mgr.projects_dim,
dw_mgr.organizations organizations_cost,
dw_mgr.organizations hyperion_organizations
WHERE
--Fact to Org on Company Code / Cost Center
(dw_mgr.fa_trans_fct.asset_cost_center_id
= organizations_cost.cost_center_id)
AND (dw_mgr.fa_trans_fct.asset_cost_company_code
= organizations_cost.company_code)
--Fact to Projects Dim on Proj Num
AND (dw_mgr.projects_dim.project_num = dw_mgr.fa_trans_fct.project_num)
--Fact to Accounts_Dim_Dep on Account ID
--convert account_ID …Run Code Online (Sandbox Code Playgroud) 我有应用程序代码,在本地数据库中插入记录,在远程数据库中插入记录(通过Oracle数据库链接).当我提交这个分布式事务时,它保证本地和远程数据库都将提交或同时回滚,或者远程可能提交但是本地提交会失败(反之亦然)?
有人可以说我可以在TransactionScope中使用npgsql吗?
在此手册中提供的代码示例:http://npgsql.projects.postgresql.org/docs/manual/UserManual.html不起作用.它只是在服务器上创建两个准备好的事务.
我遇到与此问题相同的问题:TransactionScope和Npgsql - 准备好的事务问题
在TransactionScope中使用npgsql有什么解决方案吗?
UPD:首先我的目标:我需要在我的软件中使用单个逻辑转换中的两个连接.对此最好的解决方案是TransactionScope.Npgsql声明支持在系统事务中进行登记.
然后我麻烦了:我使用文档中的代码,这段代码做了下面的事情:
我等了,9步后的数据将完全提交给db.实际上,在步骤6和7中,npgsql创建准备好的事务,并且在步骤9中什么都不做.最后我有两个预先准备好的交易,即阻止数据库.没有人可以提交或回滚它们.
通常如果我在范围内调用完成之前关闭连接(例如因为异常)npgsql创建阻止表的准备事务.我认为这不是严谨的行为.我等待范围处理数据完全提交或完全回滚后.没有任何准备好的交易.
您可以使用文档中的代码重复此错误.供参考Devart免费库工作正确.
postgresql transactions distributed-transactions prepared-statement npgsql
我是DDD的新手.现在我正在看域名活动.我不确定我是否正确理解了这个域事件,但我只想到如果域事件发布失败会发生什么?
我这里有个案子.当买家从我的网站订购商品时,首先我们将创建一个对象,订单包含一系列商品.将发布域事件OrderWasMade以扣除库存中的库存.所以在这种情况下,如果在处理事件时,项目数量将被扣除,但是如果系统试图扣除库存,则发现该项目没有剩余库存(金额= 0) .因此,物品金额不能扣除,但订单已经提交.
这种情况会发生吗?
很抱歉在这里有其他2个问题.
似乎每个事件都在自己的事务范围内,这意味着系统需要立即打开多个数据库连接.所以,如果我使用IIS服务器,我必须启用DTC,我是否正确?
域事件和域服务之间是否存在任何关系?
domain-driven-design distributed-transactions domainservices domain-events
我想在这里了解几件事。我的要求是,我想将记录存储在db中,并希望将消息发送到队列,然后如果抛出某些异常,则我希望以相同的方法说,我不想发送消息,也不想提交db事务。现在我想到了使用Spring事务,但是由于使用了两个不同的资源,想到了使用JTA使用一些atomikos来同步资源-但是我再次阅读了RMQ不支持2PC或XA等。无论如何,我继续尝试并没有添加atomikos首先尝试了所有这样做是为了确保我的频道已处理完毕,并且@Transaction批注已处理完毕,请参见下面的示例代码-我没有在pom中添加任何特殊内容。
现在我的问题是这是如何工作的,它与2PC有什么不同-方法可能出什么问题,什么情况会破坏使用此方法的最终一致性。令人惊讶的是,为什么我不必使用第三方jta。如果一切都很好-在我看来这最终保证了我们在使用Spring Goodies的rmq和db时的一致性!对于微服务:)
如果这不是一个好的解决方案,那有什么替代方案-如果可能的话,为了最终的一致性,我想避免使用工人流程等。
@Bean
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
rabbitTemplate.setChannelTransacted(true);
return rabbitTemplate;
}
@GetMapping
@Transactional
public void sampleEndpoint(@RequestParam boolean throwException){
Customer a=new Customer();
a.setCustomerName("XYZ");
customerRepository.save(a);
rabbitTemplate.convertAndSend("txtest","Test");
if(throwException)
throw new RuntimeException();
}
Run Code Online (Sandbox Code Playgroud)
我在上面的示例中使用Spring Boot 1.5.7使用了postgres依赖关系
distributed-transactions spring-transactions spring-rabbit spring-amqp spring-rabbitmq
oracle ×2
sql ×2
transactions ×2
npgsql ×1
ora-01722 ×1
oracle10g ×1
postgresql ×1
spring-amqp ×1