Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequence processing with Azure Function & Service Bus

I have an issue with Azure Function Service Bus trigger. The issue is Azure function cannot wait a message done before process a new message. It process Parallel, it not wait 5s before get next message. But i need it process sequencecy (as image bellow). How can i do that?

[FunctionName("HttpStartSingle")]
    public static void Run(
 [ServiceBusTrigger("MyServiceBusQueue", Connection = "Connection")]string myQueueItem,
[OrchestrationClient] DurableOrchestrationClient starter,
ILogger log)
    {
        Console.WriteLine($"MessageId={myQueueItem}");
        Thread.Sleep(5000);
    }

enter image description here

like image 910
TuanDPH Avatar asked May 31 '19 09:05

TuanDPH


People also ask

Can Azure Functions be used for processing data streams?

Whether you're building a web API, responding to database changes, processing IoT data streams, or even managing message queues - every application needs a way to run some code as these events occur. To meet this need, Azure Functions provides "compute on-demand" in two significant ways.

What is difference between event grid and event hub?

Event hub is a managed service that helps ingest, process, and monitor events from any source so you can build dynamic data pipelines for real-time analytics. Event grid is a fully managed event routing service that allows you to easily publish and subscribe to events across your ecosystem.

Is Azure Service Bus queue FIFO?

One of the patterns easily supported by the Azure Service Bus is the 'first-in-first-out' (FIFO) pattern – which isn't supported in the other queue service – Azure Storage Queues.

Which kind of azure function should be used to create a reliable message queue system?

Azure Logic Apps or durable functions are a natural fit to manage the workflow and circuit state. Other services may work just as well, but logic apps are used for this example. Using logic apps, you can pause and restart a function's execution giving you the control required to implement the circuit breaker pattern.

What is order processing in Azure Stream Analytics?

Stream processing technologies such as Spark or Azure Stream Analytics can process messages in order within a time window. You have messages that arrive in order and must be processed in the same order. Arriving messages are or can be "categorized" in such a way that the category becomes a unit of scale for the system.

How do Azure Functions work with sessions?

Each Azure Functions instance will acquire a lock on a session (patient), process any messages that are available, and then move on to another patient that has messages available. Sessions are currently available in the Microsoft.Azure.WebJobs.Extensions.ServiceBus extension using version >= 3.1.0, and at the time of writing this is in preview.

How to implement Azure service bus on Azure Functions?

On Azure, this pattern can be implemented using Azure Service Bus message sessions. For the consumers, you can use either Logic Apps with the Service Bus peek-lock connector or Azure Functions with the Service Bus trigger.

Is it possible to program in an asynchronous manner in Azure Functions?

Sometimes we may have to program in an asynchronous manner (eg: if we want to talk with DB from the function / CRUD operation) and it is listed as one of the best practice for the development of Azure Functions. In this post, we will discuss how to create Azure Functions that do operations in an async manner.


1 Answers

I resolved my problem by using this config in my host.json

{
"version": "2.0",
"extensions": {
    "serviceBus": {
        "messageHandlerOptions": {
            "maxConcurrentCalls": 1
        }
    }
}}
like image 86
TuanDPH Avatar answered Oct 19 '22 00:10

TuanDPH