我想编写一个使用事件
调用类型的AWS Lambda。根据java-programming-model-handler-types我应该执行以下操作:
If you plan to invoke the Lambda function asynchronously (using the Event invocation type), the outputType should be void. For example, if you use AWS Lambda with event sources such as Amazon S3, Kinesis, and Amazon SNS, these event sources invoke the Lambda function using the Event invocation type.
我正在寻找有关如何编写此类处理程序(Java)方法的示例。
有很多使用 RequestResponse
调用类型的 Java 处理程序示例(例如,public String myHandler(int myCount, Context context)
)。还有例子for using streams (IIUC 也仅适用于 RequestResponse
调用类型)。我找不到处理程序正在处理 Event
调用类型的 Java Lambda 的任何示例
最佳答案
它看起来像这样:
public class MyFunction implements RequestHandler<eventType, Void> {
public Void handleRequest(eventType event, Context context) {
...
return null;
}
}
诀窍是知道您的事件类型是什么类别。您可以将 eventType 设置为 Object,使您的函数被触发一次,并让它在函数中打印类名以找出事件类型。
关于java - 具有事件调用类型的AWS lambda java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47085166/