简体   繁体   English

我如何调用“sendTaskSuccess”将令牌返回到 stepfunction 中等待的 state。 不使用 lambda function

[英]How can i call "sendTaskSuccess" that return the token to a waiting state in stepfunction. not using lambda function

I have an external service which is called by a state in aws step function, now from this external service i want to send "sendTaskSuccess" to the particular aws step machine.我有一个外部服务,在 aws 步骤 function 中由 state 调用,现在我想从这个外部服务发送“sendTaskSuccess”到特定的 aws step 机器。 How can i do that.我怎样才能做到这一点。 I know that we can call "sendSuccessToken" from lambda but want to know how to use "sendSuccessToken" without lambda.我知道我们可以从 lambda 调用“sendSuccessToken”,但想知道如何在没有 lambda 的情况下使用“sendSuccessToken”。

The state machine ARN is not used.The step in the state machine that await a callback have a taskToken which uniquely identifies a specific task and a specific execution of state machine.未使用 state 机器 ARN。等待回调的 state 机器中的步骤有一个 taskToken,它唯一标识特定任务和 state 机器的特定执行。

The ideal way to do this would be: Step 1: Store the taskToken in a persistent storage before invoking the external service执行此操作的理想方法是:第 1 步:在调用外部服务之前将 taskToken 存储在持久存储中

export const lambdaHandler: ProxyHandler = async (event, context) => {

    const evt = JSON.parse(JSON.stringify(event));
    const taskToken = evt['token'];
    
    const dbObject = 
    {
        SomeHelpfulInfo: 'set a suitable identifier',
        taskToken:taskToken
    };
    StoreTaskToken(dbObject);
    //call external service as per your logic
//

}

Step 2: Read the taskToken from the persistent storage and invoke the step function task success第二步:从持久化存储中读取taskToken,调用步骤function任务成功

import { StepFunctions } from 'aws-sdk';

const stepfunctions = new StepFunctions();

const taskToken = GetTaskTokenFromDb(); //Have your implementation to get taskToken

const params = {
            output: '',
            taskToken: taskToken
        };
        
let result = await stepfunctions.sendTaskSuccess(params).promise();
console.log('State machine - callback completed..');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 AWS CDK 中的 InvokeLambda 将 JSON 传递给 AWS StepFunction 中的 lambda - How do I pass JSON to lambda in AWS StepFunction using InvokeLambda in AWS CDK AWS Step function 任务令牌 sendTaskSuccess 跨区域 - AWS Step function task token sendTaskSuccess cross region 如何使用动态时间延迟调用 lambda function - How can I delay call lambda function with dynamic time 使用“Pre Token Generation Lambda Trigger Function”时,如何设置“claimsToAddOrOverride”以返回数组而不是字符串 - When using the "Pre Token Generation Lambda Trigger Function", how do I set the "claimsToAddOrOverride" to return an array instead of a string 在 lambda 超时之前,如何为运行时间更长的进程返回对 AWS lambda function 的响应? - How can I return a response to an AWS lambda function for a longer running process before lambda times out? 如何使用 AWS CLI 创建 AWS Lambda 函数? - How can I create an AWS Lambda function using the AWS CLI? 如何使用 Terraform 定义 lambda function 测试事件? - How can I define lambda function test events using Terraform? 我如何使用 boto3 触发 Lambda function - how I can trigger Lambda function using boto3 如何使用 java 代码调用在 SAM localhost:3001 上运行的 AWS lambda function - How can I invoke a AWS lambda function running on SAM localhost:3001 using java code 如何使用 AWS Lambda 函数从 S3 解码 a.gz 文件? - How can I decode a .gz file from S3 using an AWS Lambda function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM