Living an Organic Lifestyle

Living an organic lifestyle means making conscious choices to prioritize natural and sustainable practices in various aspects of daily life. Here are some key areas where you can incorporate organic…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Designing restaurant order processing workflow using AWS Step Functions

Order processing is a complex business process as it involves multiple steps and actions that make up a workflow. Starting from submitting an order to fulfillment there are multiple activities containing business logic and rules in the end-to-end process. Traditionally, when building such a workflow, this logic had to be embedded in code with nested , multiple branches and relying on the database to keep track of the state. Additionally, handling timeouts and retries required a separate process to be coded.

In this article, we will look at how we can address these challenges and simplify the development of such workflows.

Solution:

AWS Step functions and event-driven architecture using AWS EventBridge helps solve these issues. AWS Step functions can construct a state machine and can handle different steps in the workflow. It provides orchestration of workflows using lambda’s, Eventbridge and many more actions. Step Functions manages state, checkpoints and restarts and provides built-in capabilities to automatically deal with errors and exceptions

AWS Eventbridge helps to decouple the microservices by routing events to appropriate microservices using event rules.

Below diagram depicts the solution for order workflow:

The architecture consists of :

POS Terminal : It is a point of sale terminal system used by restaurant staff like servers, bartenders to key in orders.
Kitchen Display System (KDS) : It is a digital screen that provides display of the orders to the kitchen staff. The staff can update the order status once the order is prepared.

Microservices:
Built using AWS Lambda and DynamoDB. The microservices communicate with each other using events.
Order service : This service handles order related operations like create, update, cancel.
Fulfillment service : This service handles integration with KDS and handles updates to order status.

EventBridge : Routes the events to appropriate targets based on event rules.

AWS Step Function : Handles the order processing workflow.

The process works as follows:

6. The Kitchen Display System (KDS) displays the order details on screen. KDS is connected to fulfillment service via websockets and hence recieves real time updates on display. KDS is used by the kitchen staff (chefs, etc). They read the orders and once the order is prepared, they update the status in KDS to Order Complete.

7. The fulfillment service then invokes a callback on Step function using “SendTaskSuccess” API and passes the taskToken generated in Step 5. This lets the step function to come out of the wait state and resume further execution. Below is a sample payload sent by fulfillment service to step function containing the taskToken.

The step function then emits a “Order Completion” event on EventBridge which contains the output of the execution. This event is directed to Order service by event bridge ruleset. The order service then refreshes the order status displayed on POS Terminal.

Conclusion

We learned how AWS Eventbridge can help in building a loosely coupled event-driven architecture. Also we learned how step functions can help to orchestrate the workflow and decouple the workflow handling task from business logic. This enables the developers to focus more on the core functionality and eliminates the need to handle complexity of workflow management, retries and failures.

References and Further Reading:

Add a comment

Related posts:

1. The Importance of Engaging Content

Social media has become an essential part of our lives, with billions of people actively using various platforms to connect, share, and engage with others. Social media is a great way for businesses…