Fully Success Transaction

here, the SEC has successfully executed all the executors. therefore, there is no Compensating/revert execution was invoked. this is the success scenario we wish.

StackSaga High-level architecture
  • 1 As the first step the user makes the request and the OrderController catch the request.

  • 2 After having the request, initialize the place order aggregator and set the start executor into the StackSaga. (In this time you have the transaction uid which is created by framework. The transaction uid is the unique id for identifying each transaction. You can get it from your created Aggregator object.)

  • 3 now the execution processes are handled by the SEC. Before invoking the executor that you provided as the start-executor SEC saves the initial state of the aggregator in the event-tore.

  • 4 SEC executes the start-executor ([Command] CreateOrderExecutor) that you provided. 4.1 due to the executing the process method by the SEC, the InternalOrderService’s createOrder() method will be invoked. 4.2 after successfully invoking the method, SEC will store the state of the aggregator. 4.3 after saving the state in the event-store, SEC will execute the onEachProcessPerformed method of the handler class that you provided. 4.4 then you can put your execution here to update the status of the place-order transaction. as the diagram, we have executed updateCustomerOrderStatus() method of InternalOrderService to update the status. 4.5 after updating the status of the place-order, you can notify your customer by sending the email or SMS or whatever method about the status of the order.

  • 5 SEC executes the 2nd executor that you provided from the 1st executor. 5.1 due to the executing the doProcess method of the [Query] UserExecutor by the SEC, the ExternalUserStatusService’s checkUser() method will be invoked. 5.2 the ExternalUserStatusService will call the user-service and make a request. 5.3 after successfully invoking the request, SEC will store the state of the aggregator of 2nd process. 5.4 after saving the state in the event-store, SEC will execute the onEachProcessPerformed method of the handler class that you provided.

    Due to this executor is a query executor, there is no status update process has been executed here.

  • 6 SEC executes the [Command] PaymentExecutor executor that you provided. 6.1 due to the executing the process method by the SEC, the ExternalPaymentService’s makePayment() method will be invoked. 6.2 the ExternalPaymentService will call the payment-service and make a request to make-payment process. 6.3 after successfully making the request, SEC will store the state of the aggregator. 6.4 after saving the state in the event-store, SEC will execute the onEachProcessPerformed method of the handler class that you provided. 6.5 then you can put your execution here to update the status of the place-order transaction. as the diagram, we have executed updateCustomerOrderStatus() method of InternalOrderService to update the status. 6.6 after updating the status of the place-order, you can notify your customer by sending the email or SMS or whatever method about the status of the order.

  • 7 SEC executes the [Command] DeliveryExecutor that you provided. 7.1 due to the executing the process method by the SEC, the ExternalDeliveryService’s addToDelivery() method will be invoked. 7.2 the ExternalDeliveryService will call the delivery-service and make a request to add-to-delivery process. 7.3 after successfully making the request, SEC will store the state of the aggregator. 7.4 after saving the state in the event-store, SEC will execute the onEachProcessPerformed method of the handler class that you provided. 7.5 then you can put your execution here to update the status of the place-order transaction. as the diagram, we have executed updateCustomerOrderStatus() method of InternalOrderService to update the status. 7.6 after updating the status of the place-order, you can notify your customer by sending the email or SMS or whatever method about the status of the order.

  • 8 as the final step the SEC will invoke the onTransactionCompleted method of the handler. 8.1 you can update the place-order status as the final state as success. 8.2 after updating the place-order status, you can notify it to the customer.