调用AWS Lambda函数,将入站消息data作为请求payload发送。节点使用RequestResponse调用类型同步执行函数,并将Lambda函数的响应作为出站消息的data返回。函数名和qualifier可根据入站消息动态填充。
配置
Function configuration(函数配置)
定义目标Lambda函数及调用方式。函数名和qualifier均支持 templatization 以动态融入入站消息数据。
Function name
The name or Amazon Resource Name (ARN) of the Lambda function to invoke. This field is required and cannot be blank.
You can specify the function name in several formats:
- Function name:
my-function - Partial ARN:
123456789012:function:my-function - Full ARN:
arn:aws:lambda:us-west-2:123456789012:function:my-function
Qualifier
Specifies a version or alias of the Lambda function to invoke. This field is optional and defaults to $LATEST if not specified.
Common qualifier values:
$LATEST– Invokes the latest unpublished version- Version number (e.g.,
1,2) – Invokes a specific published version - Alias name (e.g.,
PROD,DEV) – Invokes the version associated with an alias
AWS Credentials
Provide authentication credentials to access your AWS Lambda service.
AWS Access Key ID
The access key ID for your AWS account. This credential is used to sign requests to AWS Lambda. This field is required and cannot be blank.
AWS Secret Access Key
The secret access key corresponding to your access key ID. This field is required and cannot be blank.
AWS Region
The AWS region where your Lambda function is deployed. This field is required and cannot be blank. The region must match the location of your Lambda function.
Example values:
us-east-1(US East, N. Virginia)eu-west-1(Europe, Ireland)ap-southeast-1(Asia Pacific, Singapore)
Advanced settings
Connection timeout
The maximum time (in seconds) to wait for establishing a connection to AWS Lambda before the request fails. Default: 10 seconds.
This timeout applies only to the connection phase, not the entire request.
Request timeout
The maximum time (in seconds) to wait for the Lambda function to process the request and return a response before the request fails. Default: 5 seconds.
This timeout applies to the entire request-response cycle after the connection is established.
Tell Failure if AWS Lambda function execution raises exception
Controls how the node handles Lambda function errors.
- Enabled – If the Lambda function execution results in an error (indicated by a non-null
FunctionErrorfield in the response), the message is routed to theFailureconnection. The function’s error response is included in the failure message. - Disabled (Default) – The node routes the message to the
Successconnection regardless of whether the Lambda function encountered an error. The response (including any error information) is passed through as the message data.
JSON Schema
消息处理算法
- 节点构建Lambda调用请求:
- The function name and qualifier (if specified) are processed, replacing templates with values from the incoming message data and metadata.
- An
InvokeRequestis created with the message data as the payload and the RequestResponse invocation type.
- The invocation request is sent asynchronously to AWS Lambda with the configured timeouts:
- Connection timeout applies to establishing the connection to AWS Lambda.
- Request timeout applies to waiting for the Lambda function to complete and return a response.
- When Lambda responds:
- If Tell Failure if AWS Lambda function execution raises exception is enabled and the response contains a function error (non-null
FunctionErrorfield), the message is routed to theFailureconnection with the error details. - Otherwise, the Lambda function’s response payload is extracted and replaces the incoming message data.
- The request ID from AWS is added to the message metadata.
- The originator and message type from the incoming message remain unchanged.
- If Tell Failure if AWS Lambda function execution raises exception is enabled and the response contains a function error (non-null
- The resulting message is forwarded via the
Successconnection (orFailureif an error was detected and the setting is enabled).
输出连接
- Success
- The Lambda function was invoked successfully and returned a response within the configured timeout.
- This connection is used regardless of whether the Lambda function itself encountered an error, unless Tell Failure if AWS Lambda function execution raises exception is enabled.
- Failure
- Failed to establish a connection to AWS Lambda within the configured Connection timeout.
- The Lambda function did not respond within the configured Request timeout.
- Invalid AWS credentials or insufficient permissions to invoke the Lambda function.
- The specified Lambda function does not exist or is not accessible in the specified region.
- The Lambda function execution resulted in an error and Tell Failure if AWS Lambda function execution raises exception is enabled.
- An unexpected error occurred during processing.
示例
示例1 — 基本调用
调用处理入站消息数据并返回转换结果的Lambda函数。
入站消息
Data:
1
2
3
4
{
"value": 100,
"multiplier": 3
}
Node configuration
1
2
3
4
5
6
7
8
9
10
{
"accessKey": "AKIAIOSFODNN7EXAMPLE",
"secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"region": "us-east-1",
"functionName": "calculate",
"qualifier": "$LATEST",
"connectionTimeout": 10,
"requestTimeout": 5,
"tellFailureIfFuncThrowsExc": false
}
Lambda function response
1
2
3
4
{
"result": 300,
"operation": "multiplication"
}
出站消息
Metadata (with added requestId):
1
2
3
{
"requestId": "1234abcd-56ef-78gh-90ij-klmnopqrstuv"
}
Data:
1
2
3
4
{
"result": 300,
"operation": "multiplication"
}
Routed via the Success connection.
结果
Lambda函数收到入站消息数据并执行计算后返回结果。原始消息data被Lambda函数响应替换,AWS请求ID已添加到metadata。
示例2 — 错误处理
Invoke a Lambda function that validates input data. When the function detects invalid input and raises an exception, the node routes the message to the Failure connection.
Incoming message
Data:
1
2
3
{
"value": -50
}
Node configuration
1
2
3
4
5
6
7
8
9
10
{
"accessKey": "AKIAIOSFODNN7EXAMPLE",
"secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"region": "us-east-1",
"functionName": "validate",
"qualifier": "$LATEST",
"connectionTimeout": 10,
"requestTimeout": 5,
"tellFailureIfFuncThrowsExc": true
}
Lambda function behavior
The Lambda function detects that the value is negative and throws an exception:
1
Validation error: Value must be positive
出站消息
Data (original message data preserved):
1
2
3
{
"value": -50
}
Metadata:
1
2
3
4
{
"error": "class java.lang.RuntimeException: Validation error: Value must be positive",
"requestId": "5678wxyz-12ab-34cd-56ef-ghijklmnopqr"
}
Routed via the Failure connection.
结果
Lambda函数抛出异常。因 Tell Failure if AWS Lambda function execution raises exception 已启用,节点捕获该错误并将消息路由到 Failure 连接,metadata中包含错误详情。