After this section, you will have a workflow that is ready to support the drink ordering application.
First, test the workflow with the store open, which is the default state when you run the setup module.
Go to the Step Functions console. From the AWS Management Console, select Services then select Step Functions under Application Integration. Make sure your region is correct.
Under State machines, select OrderProcessorWorkflow. On the page showing the workflow, choose Start execution.
In the Start execution pop-up, enter the following JSON payload, then choose Start execution:
{
"detail": {
"orderId": "1",
"userId": "testuser"
}
}
The shop’s state is stored in the DynamoDB configuration table for the application. The Is the shop open? transition checks this value and uses a Step Functions choice state to determine the flow. Here, you will toggle this state and run executions to test the outcome.
Go to the DynamoDB console. From the AWS Management Console, select Services then select DynamoDB under Database. Make sure your region is correct.
From the left-hand menu, choose Explore items in the Tables menu. Choose serverlesspresso-config-table in the Tables list.
storeOpen
to false
.{
"PK": "config",
"storeOpen": false,
"maxOrdersPerUser": 1,
"maxOrdersInQueue": 10
}
Choose Save changes to update the table.
Go to the Step Functions console. From the AWS Management Console, select Services then select Step Functions under Application Integration. Make sure your region is correct.
Under State machines, select OrderProcessorWorkflow. On the page showing the workflow, choose Start execution.
In the Start execution pop-up, enter the following JSON payload, then choose Start execution:
{
"detail": {
"orderId": "1",
"userId": "testuser"
}
}
The workflow has emitted an event indicating that the shop is unavailable. This can be consumed by other microservices in the application to take appropriate actions.
Set the store back to “open” in the DynamoDB table. 1. Go to the DynamoDB console. From the AWS Management Console, select Services then select DynamoDB under Database. Make sure your region is correct.
From the left-hand menu, choose Explore items in the Tables menu. Choose serverlesspresso-config-table in the Tables list.
Choose the config item in the Items returned panel. This opens the item editor.
Set the store back to open. Paste the following JSON, which sets storeOpen
to true
.
{
"PK": "config",
"storeOpen": true,
"maxOrdersPerUser": 1,
"maxOrdersInQueue": 10
}
Next, you will set up and configure events that allow other microservices to react to changes in this workflow.