Callback tasks provide a way to pause a workflow until a task token is returned.
A task might need to wait for a human approval, integrate with a third party, or call legacy systems.
For tasks like these, you can pause Step Functions indefinitely, and wait for an external process or workflow to complete.
For these situations Step Functions allows you to pass a task token to the AWS SDK service integrations, and also to some Optimized service integrations.
The task will pause until it receives that task token back with a SendTaskSuccess or SendTaskFailure call.
In this video , this topic is explained with in-depth intuition.
Prerequisite:
-----------------------
Send message from Step Function to SQS directly | in-depth intuition
• Send message from Step Function to SQS dir...
Documentation Link:
--------------------------------------
https://docs.aws.amazon.com/step-func...
Boto3 Documentation Link :
-----------------------------------------------
https://boto3.amazonaws.com/v1/docume...
Step Function Code:
----------------------------------
{
"Comment": "A description of my state machine",
"StartAt": "SQS SendMessage",
"States": {
"SQS SendMessage": {
"Type": "Task",
"Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
"Parameters": {
"MessageBody": {
"input.$": "$",
"MyTaskToken.$": "$$.Task.Token"
},
"QueueUrl": "{}"
},
"Next": "Pass"
},
"Pass": {
"Type": "Pass",
"End": true
}
}
}
Lambda Function Code:
----------------------------------------------
import json
import boto3
import time
client = boto3.client('stepfunctions')
def lambda_handler(event, context):
TODO implement
print(event)
main_message=json.loads(event['Records'][0]['body'])
print("Main Message Part : {}".format(main_message))
step_fucntion_input=main_message['input']
print("The comment is : {}".format(step_fucntion_input['Comment']))
print("The Hello is : {}".format(step_fucntion_input['Hello']))
task_token=main_message['MyTaskToken']
print("The task token is : {}".format(task_token))
time.sleep(20)
response = client.send_task_success(
taskToken=task_token,
output=json.dumps({'body':'Return from Lambda Callback'})
)
Learn AWS Step Function from Scratch:
• AWS Step Functions Simplified
Check this playlist for more AWS Projects in Big Data domain:
• Demystifying Data Engineering with Cloud C...
🙏🙏🙏🙏🙏🙏🙏🙏
YOU JUST NEED TO DO
3 THINGS to support my channel
LIKE
SHARE
&
SUBSCRIBE
TO MY YOUTUBE CHANNEL
En esta página del sitio puede ver el video en línea Callback Pattern using AWS Step function + SQS queue + Lambda in Python de Duración hora minuto segunda en buena calidad , que subió el usuario Knowledge Amplifier 01 octubre 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 5,163 veces y le gustó 69 a los espectadores. Disfruta viendo!