How to control messages on a bus coming from Dynamics

Claude VERNIER 61 Reputation points
2024-04-02T07:50:07.7533333+00:00

Hello,

I am seeking guidance and best practices on a scenario I have.

We have a Dynamics site that enables clients to book seats in a theatre with several rooms and while the clients updates fields on Dynamics we want to update a database on a different ecosystem.

We have an Azure bus that triggers an Azure Function to call methods from an APIM to call APIs that will update the SQL database.

When the client creates or updates any field of the request such as:  showId (PK), roomId, showDate, showTime, extraService1, extraService2, clientName, clientAddress, it generates a message on the bus with only the requestId and the Azure function gets the latest information from Dynamics to build an Insert/Update statement to update SQL.

What would be the best approach to have the best efficiency of the inserts and update. It can happen that a message tries to update the roomId before the showId creation and there can be many messages that updates the same values repeatedly. How can we make sure to process the messages in the correct order and avoid updating several times the same values.  Are there features on the Azure Service Bus that can help on such a scenario, is there sample project we could use as first steps.

Many thanks.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,171 questions
Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
635 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,090 questions
Dynamics 365 Training
Dynamics 365 Training
Dynamics 365: A Microsoft cloud-based business platform that provides customer relationship management and enterprise resource planning solutions.Training: Instruction to develop new skills.
147 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,531 Reputation points
    2024-04-02T09:37:00.01+00:00

    @Claude VERNIER Thanks for reaching out.

    From service bus prospective to ensure that messages are processed in the correct order, you can use the Service Bus Sessions feature. This feature allows you to group related messages together and process them in the order they were received. In your case, you can group messages by requestId, so that messages related to the same request are processed in order. You can also use the Service Bus Lock Duration feature (while consuming the message you can use Peek lock mode) to ensure that messages are not processed by multiple consumers at the same time.

    To avoid updating the same values repeatedly, you can use the Service Bus Duplicate Detection feature. This feature allows you to configure a time window during which messages with the same messageId are considered duplicates and are not processed.

    In your case, you can use the requestId as the messageId to ensure that messages related to the same request are not processed multiple times.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.