简体   繁体   English

SQL Server与Azure Eventhub + Logic应用程序并行插入

[英]SQL Server parallel inserts with Azure Eventhub + Logic app

I'm using Azure Event Hub to stream Azure diagnostics data to a Logic app to save it into an Azure SQL table for monitoring purposes. 我正在使用Azure Event Hub将Azure诊断数据流式传输到Logic应用程序,以将其保存到Azure SQL表中以进行监视。 This works great. 这很好。 However, it sometimes occurs that EventHub sends duplicates. 但是,有时会发生EventHub发送重复项的情况。 To avoid duplicate inserts I'm using a INSERT INTO statement with a WHERE NOT EXISTS clause. 为了避免重复插入,我使用带有WHERE NOT EXISTS子句的INSERT INTO语句。 However, very infrequently I am still getting double rows. 但是,我很少会得到双排。 The Logic app runs parallel so I guess this is causing the issue. 逻辑应用程序并行运行,因此我认为这是造成此问题的原因。 I think sometimes it does the same insert on exactly the same time, which causes the WHERE NOT EXISTS clause not to work. 我认为有时它会在完全相同的时间执行相同的插入操作,这会导致WHERE NOT EXISTS子句无法正常工作。

Does anyone know a workaround? 有谁知道解决方法? i'd rather not do a DELETE from and remove duplicate rows afterwards as I want to put a unique key constraint on the table. 我宁愿不执行DELETE操作,然后再删除重复的行,因为我想在表上放置唯一的键约束。

You have to have some idempotency checking in you function. 您必须在功能中进行一些幂等性检查。 When scaling happens the new scale unit will take over processing a partition and thus reprocess the same messages. 发生缩放时,新的缩放单元将接管分区的处理,从而重新处理相同的消息。

I don't know if Service Bus can queue those messages. 我不知道Service Bus是否可以将这些消息排队。 I advise you to report to the Event Hubs team. 我建议您向事件中心团队报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM