I am trying to understand what's the best practice here in this specific use case of ours.
- We have an Orders Microservice.
- We have to accept requests via an API from user-facing client apps that is directed to our processing logic.
- We have to also read from a Service Bus Queue to which a third-party system sends webhooks to, and that payload needs to be processed by the exact same Order processing logic.
What is the best practice to architect this? I can think of 3 approaches:
Have an API exposed from the Orders Microservice and also have a Service Bus Queue consumer on the same service, which reads from the Queue and sends it to order processing logic. Here except for the method through which we receive the request (API vs. Queue) everything remains the same. But I have a feeling that an API and a Worker (listening to queue) being present in a single app service is not a good practice and causes deep coupling.
Another approach is to only Expose an API from the Order Microservice and do not have a queue consumer there. Create a new app service (.net core worker) that reads from the queue and then POSTs the payload to the Orders API. This seems like a better approach, but we have several microservices just like the Orders service and do not want to take the overhead of creating one AppService/Worker per queue since consuming from multiple queues from a single worker/app service is not a good practice.
Third approach is to have an Azure Event Grid read from the Service Bus Queue and then post it to the Orders API. This way we can easily create Topics and Subscriptions and direct service bus queue messages to API without much overhead.
Please provide recommendations based on Microservices Best Practices.