← Back to list

AWS Step Function Manual Activities and Dynamo DB with Java SDK

AWS Step Functions is a service provided by Amazon Web Services that makes it easier to orchestrate multiple AWS services to accomplish…

Nilay Tiwari · 2020-03-05 06:00 · 2 claps · 2.5 min read
#aws-step-functions #aws-lambda #spring-boot #manual-action
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud

AWS Step Function Manual Activities and Dynamo DB with Java SDK

AWS Step Functions is a service provided by Amazon Web Services that makes it easier to orchestrate multiple AWS services to accomplish tasks. Step Functions allows you to create steps in a process where the output of one step becomes the input for another step, all using a visual workflow editor.

Majorly AWS Step Function is used to orchestrate AWS services with workflow. We created one POC for the Manual activity . Used AWS Step Function for end to end Patient & Doctor appointment Flow. We Named this workflow eCare. Created a back-end(Rest API) for the same.

Please refer AWS document to learn Basic for the AWS Step Function

https://docs.aws.amazon.com/step-functions/latest/dg/getting-started.html

Following workflow we created in AWS Step Function .

eCare Work flow.

eCare Work flow.

Following architecture is create to build eCare Application

eCare Architecture

eCare Architecture

You can Learn below AWS services with eCare -

AWS Step Function, AWS Lambda, AWS API Gateway, AWS Dynamo DB

How to Bind Activities in Workflow JSON

Activity is just a task, you can bind a worker with an activity and execute that worker in aws service like EC2, AWS Lambda.

To create activity please follow the below steps

  1. In the Step Functions console, in the navigation pane on the left, choose Activities.
  2. Choose Create activity.
  3. Enter an Activity Name, for example, *get-greeting*, and then choose Create Activity.
  4. When your activity task is created, make a note of its ARN, as shown in the following screen.
  5. Bind Activities to work flow as Mentioned in given image below.

Bind Activity in AWS Step Function Workflow Json

Bind Activity in AWS Step Function Workflow Json

Execute Worker with Lambda Function and Notify the Activity

Refer the build.gradle for dependencies in github source link provided in last of this article.

//ACTIVITY_LABORATORY_ARN is the Activity ARN from your AWS account
GetActivityTaskResult getActivityTaskResult = awsStepFunctionClient.getActivityTask(new GetActivityTaskRequest().withActivityArn(ACTIVITY_LABORATORY_ARN));
//get task token from activity
String taskToken = getActivityTaskResult.getTaskToken();JsonNode json = Jackson.jsonNodeOf(getActivityTaskResult.getInput());
                String outputResult = setStatus(json.get(Params.PATIENT_ID).textValue(),false);
                String ptId = json.get(Params.PATIENT_ID).textValue();
if (patientStatusFromDB.get().getPatientId().equalsIgnoreCase(ptId)) {//check value from activity input with value received from rest

SendTaskSuccessRequest sendTaskRequest = new SendTaskSuccessRequest().withOutput(outputResult).withTaskToken(taskToken);
                    awsStepFunctionClient.sendTaskSuccess(sendTaskRequest); 
//Send success notification to task
} else {                     awsStepFunctionClient.sendTaskHeartbeat(new SendTaskHeartbeatRequest().withTaskToken(taskToken));
}

Input and result can be used to pass from One step to another and use those values in execution. You can check the above code. sendTaskSuccess method will move state machine to another activities. In case if you want to keep that state machine keep stay at the same task in case of any reason then send sendTaskHeartBeat which keep task in running state.

How to input /result flow between task

Input/Result Data flow

Input/Result Data flow

For detail please refer Source code link given below.

[embed]ERS-HCL/serverless-poc-stepfunction This POC gives the handson for below mentioned points StepFunction Uses with Java SDK AWS Lambda with Spring…github.com

Quick Learn by This POC

  1. AWS Step Function with Activities using Java SDK
  2. Spring boot based Lambda Function by considering warm-up time for IOC container initialization.
  3. AWS Spring data with Dynamo DB using Java SDK.

메타데이터
post_id
ff3fe2db47d3
slug
aws-step-function-manual-activities-and-dynamo-db-with-java-sdk-ff3fe2db47d3
url
https://medium.com/@nilay-tiw/aws-step-function-manual-activities-and-dynamo-db-with-java-sdk-ff3fe2db47d3
canonical_url
https://medium.com/@nilay-tiw/aws-step-function-manual-activities-and-dynamo-db-with-java-sdk-ff3fe2db47d3
author_url
https://medium.com/@nilay-tiw
status
ok
fetched_at
2026-06-22 17:31:34