用EventHub触发器在Azure功能中处理重复项

发布于 2025-02-07 06:19:53 字数 225 浏览 2 评论 0 原文

我有一个具有事件轮毂绑定触发器的Azure函数,并且接收了一批EventData。我也有固定的elayretry,可以为未经治疗的例外重试(故意完成)。

如果一个事件在批处理中处理过程中失败,那么整个批次将再次重试,这显然会引起重复的问题

,那么我如何确定已成功处理的事件?

是否有一个良好的模式可以存储事件序列编号和在处理之前检查它的状态?以及如何将这些信息作为Azure函数检索是无状态的。

I have an Azure Function which has Event Hub binding trigger and it receives batch of EventData. I also have FixedDelayRetry for enabling retry for unhandled exceptions (done on purpose).

If one event fails during processing it inside a batch then the whole batch is getting retry again which obviously create an issue of duplicates

So how can I identify the events which have been successfully processed?

Is there a good pattern to store event sequence number and the status to check it before processing it? and how to retrieve those information as Azure functions are stateless.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傻比既视感 2025-02-14 06:19:53

如果一个事件在批处理内处理过程中失败

根据Microsoft文档创建重复问题,因此不可能进行部分成功。

所有人都成功或失败。有关

Event Hubs专为每秒数百万个事件而设计,它不是为单个消息处理而设计的。

它在批处理上的工作,它们处理整个批处理,如果批处理失败,则再次重试特定的批次。

那么如何确定已成功处理的事件?

您可以使用尝试捕获块,如果捕获块引发异常,则在队列中添加此事件,然后用队列触发器调用另一个功能,以处理失败的事件。

是否有很好的模式存储事件序列编号

,因此需要引入分区键,这将允许您进行订购处理。

If one event fails during processing it inside a batch then the whole batch is getting retry again which obviously create an issue of duplicates

According to Microsoft Documents, partial success is not possible.

Either all Succeed or all Fail. More about EventDataBatch Class.

Event hubs is designed for millions of events per second, it's not designed for single message processing.

Its work on batches, they work on whole batch processed and if batch fail then retry the specific batch again.

So how can I identify the events which have been successfully processed?

You can use try and catch block, if catch block throws an exception then add this event in Queue and call another function with Queue trigger to process that failed events.

Is there a good pattern to store event sequence number

If you need to process multiple events in an order so you need to introduce a Partition key, which will allow you for ordered processing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文