0

I have created around 10 Microservices on .net core 2.2, MongoDB and have deployed them on Azure Kubernetes, but I am getting a hard time understanding how to manage this on the server. All services are independent of each other but have to be called in a certain order for Processing. I am confused as what would be the best solution to Design a workflow kind of architecture which can execute these service as per needs (Azure Logic apps or Function App or any other suggestions) Thanks,

Amit Singh
  • 344
  • 3
  • 18
  • why the order of processing is a concern if they are independent ? Does each microservice carry its independent database ? – Tushar Mahajan Nov 19 '19 at 11:42
  • Yes they carry independent collection in MongoDB, no service communicate to each other rather work on their own collections but they need to run on specific order as combined every service together they are performing one end to end processing – Amit Singh Nov 19 '19 at 12:13

2 Answers2

2

I guess what you're looking for is known as Saga Pattern which can be achieved through Choreography or Orchestration. You can find a very good explanation in here:

https://microservices.io/patterns/data/saga.html

PS: For Azure Functions, you can use Durable Functions and implement the Orchestration very easily:

 public static class OrderSaga
    {
        [FunctionName("OrderSaga")]
        public static async Task<bool> RunOrchestrator(
            [OrchestrationTrigger] DurableOrchestrationContext context)
        {
            var orderId = context.GetInput<Guid>();

            Task<bool> orderResponse = context.CallActivityAsync<bool>("OrderActivity", orderId);
            Task<bool> paymentResponse = context.CallActivityAsync<bool>("PaymentActivity", orderId);

            await Task.WhenAll(orderResponse, paymentResponse);

            if (orderResponse.Result == false || paymentResponse.Result == false)
            {
                await context.CallActivityAsync("RollbackOrderActivity", orderId);
                await context.CallActivityAsync("RollbackPaymentActivity", orderId);

                return false;
            }

            return true;
        }
Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
  • You can read minds, exactly what I was looking for. Thanks a ton for also filtering out Azure Functions for this. – Amit Singh Nov 20 '19 at 06:08
0

Lets say if you have an apiGateway ( the authenticator microservice or any other in your case), you can point it to a URL via ingress rule.

This service shall carry the microservice that shall be called for first part of operation and once it completes, it can send a sync call to the next microservice in hierarchy and so on..

say -

API gateway has -

service1:8080/api/{uri}

This takes you to service1, then service1 performs its task and hands over the control to service2 and so on

Tushar Mahajan
  • 2,044
  • 1
  • 7
  • 18
  • is ingress rule has a place to create or I have to modify the service and what if I want to change the flow of execution can I do that. also please share some references for sample content to check into. – Amit Singh Nov 19 '19 at 12:27
  • you can refer https://stackoverflow.com/questions/58604021/expose-a-kubernetes-deployment-frontend-using-ingress-controller/58604282#58604282 for the ingress implementation – Tushar Mahajan Nov 19 '19 at 13:23
  • well I wasn't using any front end and not having ingress implementation but I'll look more into this thing as it would be new learning, thanks for your time bro. – Amit Singh Nov 20 '19 at 06:12