[英]How can I use Azure Service Bus transactionaly with Azure DocumentDB
I want to be able to save/update a document in DocumentDB and then publish an event on Azure Service Bus, and I want these to happen atomically. 我希望能够在DocumentDB中保存/更新文档,然后在Azure Service Bus上发布一个事件,我希望这些事件以原子方式发生。
Azure Service Bus does not support distributed transactions, so with a SQL database, I save my record and place a record in a message queue table, all within a SQL transaction. Azure Service Bus不支持分布式事务,因此对于SQL数据库,我保存记录并将记录放在消息队列表中,所有这些都在SQL事务中。 A process then reads the message queue table and places the messages on the queue and removing them from the queue when successful (utilizing Service Bus' deduplication in case a message is added twice).
然后,进程读取消息队列表并将消息放入队列并在成功时将其从队列中删除(如果消息被添加两次,则使用Service Bus的重复数据删除)。
But DocumentDB does not support transactions across collections, so I cannot update a document and then add a document to a message queue collection. 但是DocumentDB不支持跨集合的事务,因此我无法更新文档,然后将文档添加到消息队列集合中。
How can I ensure my changes to documents are published on the bus? 如何确保我对文档的更改发布在总线上?
I'm not entirely sure I understand the question, but... from a transactional standpoint, you can have both your data and your queue documents in the same collection (just make sure you have some type of differentiator such as a Type
property, for filtering). 我不完全确定我理解这个问题,但是......从事务的角度来看,你可以将你的数据和队列文档放在同一个集合中(只要确保你有一些类型的区分因素,比如
Type
属性,用于过滤)。
EDIT - to reflect triggers and transactions 编辑 - 反映触发器和事务
Futher, DocumentDB supports pre- and post-trigger operations, so you could set up a post-trigger for writing an additional document after the data document insert is complete. 此外,DocumentDB支持触发前和触发后操作,因此您可以在数据文档插入完成后设置用于编写其他文档的后触发器。 As stated in the comments (per @Ryan): The post-trigger operations are included within the transaction.
正如评论中所述(每个@Ryan):后触发操作包含在事务中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.