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
На этой странице сайта вы можете посмотреть видео онлайн Callback Pattern using AWS Step function + SQS queue + Lambda in Python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Knowledge Amplifier 01 Октябрь 2022, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 5,163 раз и оно понравилось 69 зрителям. Приятного просмотра!