Bro*_*oks 23 amazon-web-services amazon-cloudwatch aws-lambda
编写由Cloudwatch预定事件触发的AWS Java Lambda函数时,哪个事件对象会传递给Lambda处理函数?
例如,对于由S3事件触发的Lambda函数,AWS调用该函数并传递S3Event对象.类似地,它会将SNSEvent对象传递给由SNS消息触发的函数.
public class LambdaHandler {
public void eventHandler(S3Event event, Context context) {
}
Run Code Online (Sandbox Code Playgroud)
要么
public class LambdaHandler {
public void eventHandler(SNSEvent event, Context context) {
}
Run Code Online (Sandbox Code Playgroud)
对于Cloudwatch计划事件驱动的功能,将取代SNSEvent/S3Event?
public class LambdaHandler {
public void eventHandler(__________ event, Context context) {
}
Run Code Online (Sandbox Code Playgroud)
我无法为我的生活找到任何由Java编写的AWS Lambda函数的示例,这些函数由Cloudwatch Scheduled事件触发...
样本函数的加分点.
编辑1目前还没有正确答案(虽然我不知道AWS已经在SDK中发布了一个适当的'事件'对象,将被传递给Lambda函数),所以实际上可能没有答案我正在寻找.
这个问题也是在这里问:什么是由CloudWatch的事件传递给lambda函数参数类型-计划触发?有人评论建议使用Object并打印类名.原来是LinkedHashMap.看起来像我要得到的答案一样正确......
以下是它的样板代码。
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.events.ScheduledEvent;
public class CollectionLambda {
public void eventHandler(ScheduledEvent event, Context context) {
// todo
}
}
Run Code Online (Sandbox Code Playgroud)
为 maven 添加以下依赖项:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>2.2.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6922 次 |
| 最近记录: |