简体   繁体   English

如何将Azure Service Bus事务性地与Azure DocumentDB一起使用

[英]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.

相关问题 每天发送100多个消息到Azure服务总线 - Send 100+ messages transactionaly to Azure service Bus 如何在Microsoft Azure Functions中将DocumentDB数据库输入绑定与服务总线触发器绑定和BrokeredMessage一起使用? - How do I use a DocumentDB database input binding with a Service Bus trigger binding and BrokeredMessage in Microsoft Azure Functions? 我可以在Windows工作流和Azure Service Bus中使用可靠的消息传递吗? - Can I use reliable messaging with windows workflow and and azure service bus? 如何记录Azure Service Bus访问? - How can I log Azure Service Bus access? 如何自动使Azure Service Bus订阅上的消息过期? - How can I automatically expire messages on an Azure Service Bus subscription? 如何使Azure Service Bus以FIFO方式工作? - How can I get Azure Service Bus to work in a FIFO manner? 如何在 C++ 中使用 Azure 服务总线 - How to use the Azure Service Bus in C++ 如何将 ScheduledEnqueueTimeUtc 与 Azure 服务总线一起使用 - How to use ScheduledEnqueueTimeUtc with Azure Service bus Azure 服务总线如何使用 Azure AD 对客户端进行身份验证 - How can Azure Service Bus authenticate clients using Azure AD 如何从URL或Azure函数触发Azure服务总线订阅 - How can I trigger azure service bus subscription from URL or azure function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM