简体   繁体   English

Azure 作为消息队列的持久函数

[英]Azure Durable Functions as Message Queue

I have a serverless function that receives orders, about ~30 per day.我有一个无服务器 function 接收订单,每天大约 30 个。 This function is depending on a third-party API to perform some additional lookups and checks.这个 function 依赖于第三方 API 来执行一些额外的查找和检查。 However, this external endpoint isn't 100% reliable and I need to be able to store order requests if the other API isn't available for a couple of hours (or more..).但是,这个外部端点不是 100% 可靠,如果另一个 API 在几个小时(或更长时间......)内不可用,我需要能够存储订单请求。

My initial thought was to split the function into two, the first part would receive orders, do some initial checks such as validating the order, then post the request into a message queue or pub/sub system.我最初的想法是将 function 分成两部分,第一部分将接收订单,进行一些初始检查,例如验证订单,然后将请求发布到消息队列或发布/订阅系统中。 On the other side, there's a consumer that reads orders and tries to perform the API requests, if the API isn't available the orders get posted back into the queue.另一方面,有一个消费者读取订单并尝试执行 API 请求,如果 API 不可用,订单将被发送回队列。

However, someone suggested to me to simply use an Azure Durable Function for the requests, and store the current backlog in the function state, using the Aggregator Pattern (especially since the API will be working find 99.99..% of the time).然而,有人建议我简单地使用 Azure 持久 Function 来处理请求,并将当前积压存储在 function state 中,使用聚合器模式(特别是因为 API 将在 99.99..% 的时间内工作)。 This would make the architecture a lot simpler.这将使架构更简单。

What are the advantages/disadvantages of using one over the other, am I missing any important considerations?使用一个比另一个有什么优点/缺点,我是否遗漏了任何重要的考虑因素? I would appreciate any insight or other suggestions you have.如果您有任何见解或其他建议,我将不胜感激。 Let me know if additional information is needed.让我知道是否需要其他信息。

You could solve this problem with Durable Task Framework or Azure Storage or Service Bus Queues, but at your transaction volume, I think that's overcomplicating the solution.您可以使用 Durable Task Framework 或 Azure 存储或服务总线队列来解决此问题,但在您的事务量下,我认为这会使解决方案过于复杂。

If you're dealing with ~30 orders per day, consider one of the simpler solutions:如果您每天要处理约 30 个订单,请考虑一种更简单的解决方案:

  • Use Polly , a well-supported resilience and fault-tolerance framework.使用Polly ,这是一个得到良好支持的弹性和容错框架。
  • Write request information to your database.将请求信息写入您的数据库。 Have an Azure Function Timer Trigger read occasionally and finish processing orders that aren't marked as complete.偶尔读取 Azure Function 计时器触发器并完成处理未标记为完成的订单。

Durable Task Framework is great when you get into serious volume.当您的工作量很大时,Durable Task Framework 非常有用。 But there's a non-trivial learning curve for the framework.但是这个框架有一个不平凡的学习曲线。

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

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