'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. Now I want to check if after 3 minutes of receiving the message another arrived.

how do I achieve this?



Solution 1:[1]

You may want to use the concept of "Timers in Durable Functions".

https://docs.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 e.g. in a webservice? I am not so sure ;)

Solution 2:[2]

In short no! You would have to poll the servicebus message queue yourself to control that behaviour.

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

What is the scenario that would require you to check for a subsequent message after 3 minutes?

Solution 3:[3]

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.

Azure Service bus can schedule or defer a message. 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.

This is rather straightforward but you’ll need a few changes to the default Function behaviour. 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. Also, the function code will now have to distinguish between “data” messages (A) and control messages (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.

But, there are alternatives. You could use Durable Functions to build your mini workflow. Or you could use one of the middleware abstractions for messaging to simplify the implementation with function. MassTransit and NServiceBus with SendLocal()would do.

And good luck with conquering Azure. There are many ways to tackle any problem. Especially with cloud providers.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 BrettMiller
Solution 3 Sean Feldman