简体   繁体   English

azure function 检查 X 分钟后是否收到消息

[英]azure function check if message received after X minutes

I am completely new to Azure and I have a function which is triggered by a service bus queue, the message is a JSON string.我是 Azure 的新手,我有一个由服务总线队列触发的 function,消息是 JSON 字符串。 Now I want to check if after 3 minutes of receiving the message another arrived.现在我想检查在收到消息 3 分钟后是否有另一条消息到达。

how do I achieve this?我如何实现这一目标?

In short no.简而言之,没有。 You would have to poll the servicebus message queue yourself to control that behaviour.您必须自己轮询服务总线消息队列才能控制该行为。

https://stackoverflow.com/a/48899686/12040634 https://stackoverflow.com/a/48899686/12040634

What is the scenario that would require you to check for a subsequent message after 3 minutes?需要您在 3 分钟后检查后续消息的场景是什么?

You may want to use the concept of "Timers in Durable Functions".您可能想使用“持久功能中的计时器”的概念。

https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-timers?tabs=csharp https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-timers?tabs=csharp

Are you using "azure functions" or do you want to have a function in azure eg in a webservice?您是在使用“天蓝色功能”还是想在网络服务中使用 azure 中的 function? I am not so sure;)我不太确定;)

I have a function which is triggered by a service bus queue… I want to check if after 3 minutes of receiving the message another arrived.我有一个由服务总线队列触发的 function……我想检查在收到消息 3 分钟后是否有另一个消息到达。

Azure Service bus can schedule or defer a message. Azure 服务总线可以安排或延迟消息。 The two are not the same.两者不一样。 Deferring means you need to keep a message and retrieve it at some point yourself.延迟意味着您需要保留一条消息并在某个时候自己检索它。 Scheduling, requires creating a new message.调度,需要创建一条新消息。 But, the two could be combined.但是,两者可以结合。 Upon receiving of the message (message A), it could be deferred and a new message scheduled (message B), with its payload being the sequence number of the message A. When the message's B time comes, it will be received by your code and you can request the deferred message B.收到消息(消息 A)后,它可以被推迟并安排一条新消息(消息 B),其有效负载是消息 A 的序列号。当消息 B 的时间到来时,它会被您的代码接收并且您可以请求延迟消息 B。

This is rather straightforward but you'll need a few changes to the default Function behaviour.这相当简单,但您需要对默认的 Function 行为进行一些更改。 You'll need to specify that your function needs to be injected with the receiver to be able to defer the incoming message A, and create a sender to post a scheduled message.您需要指定您的 function 需要注入接收方才能延迟传入消息 A,并创建一个发送方来发布预定消息。 Also, the function code will now have to distinguish between “data” messages (A) and control messages (B).此外,function 代码现在必须区分“数据”消息 (A) 和控制消息 (B)。 And that all will only work with the in-process Functions SDK as the newer, Isolated Worker SDK doesn't support Service Bus SDK types.并且所有这些都只能与进程内函数 SDK 一起使用,因为较新的 Isolated Worker SDK 不支持服务总线 SDK 类型。

But, there are alternatives.但是,还有其他选择。 You could use Durable Functions to build your mini workflow.您可以使用 Durable Functions 来构建您的迷你工作流程。 Or you could use one of the middleware abstractions for messaging to simplify the implementation with function.MassTransit and NServiceBus with SendLocal() would do.或者,您可以使用一种中间件抽象来进行消息传递,以简化 function 的实现。MassTransit和带有SendLocal SendLocal()的 NServiceBus 都可以。

And good luck with conquering Azure. There are many ways to tackle any problem.祝你征服Azure好运。有很多方法可以解决任何问题。 Especially with cloud providers.特别是对于云提供商。

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

相关问题 Azure Function 30 分钟后超时 - Azure Function Timeout after 30 minutes Azure 服务消息 - 一些消息被删除但未收到 - Azure service message - Some messages are getting deleted but not received Azure 构建后 Devops 更改消息 - Azure Devops change message after build Azure 逻辑应用程序 - 如何读取从主题收到的消息并插入到 Salesforce - Azure logic apps - How to read message received from topic and insert into Salesforce 模拟器上未收到 Firebase 消息 - Firebase message not received on emulator 将消息排队到 Azure 存储在 Azure function 中而不更改 output - Enqueueing a message to Azure Storage in an Azure function without changing the output 将 Node.js Azure Function 从 Function Extensions 2.x 迁移到 3.x 时出现问题 - Problems migrating Node.js Azure Function from Function Extensions 2.x to 3.x 调用 Azure Function(队列触发器)不起作用,但是当我从 azure 门户发送消息时它起作用 - Calling Azure Function ( Queue Trigger) Doesnt work , but it does when i send i message from azure portal Azure Function 几个小时后停止工作 - Azure Function Stops Working After a Few Hours 将 CSV output 从 Azure function 保存到 Azure 容器(Python 3X) - Saving CSV output from Azure function to Azure container (Python 3X)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM