Существует ли общее событие, которое функция AWS Lambda может получить, а затем определить, какой это тип события?JAVA

Программисты JAVA общаются здесь
Гость
Существует ли общее событие, которое функция AWS Lambda может получить, а затем определить, какой это тип события?

Сообщение Гость »


Сейчас я изучаю AWS Lambda и то, как ее запускать из других сервисов. Мне удалось использовать тему SNS (с помощью этого руководства) для публикации json типа:

Код: Выделить всё

{
"name":"Bojack",
"lastName":"Horseman",
"job":"Horsin around"
}
и запускает функцию Lambda:

Код: Выделить всё

public class LambdaHandler implements RequestHandler {

public MyResponse handleRequest(SNSEvent request, Context context){

String input = request.getRecords().get(0).getSNS().getMessage();
MyRequest myRequest = new Gson().fromJson(input, MyRequest.class);

context.getLogger().log(MyRequest.toString());

// do some logic

return null;
}
}
It works great!

However, now I'm trying to figure out how to add a new service that can also trigger this function.
For example SQS, or kinesis. AFAIK these services send different json input to the lambda function, and I'm not sure about how to receive it since I'm currently using SNSEvent

Is there a way to receive a Generic Event and inside the handler determine which service was the one who send it? So that way I can parse it to that specific event and get the message

I've read about AWS Lambda Event Source Mapping but I'm not sure if that's the way to go. Also I didn't really understand it


Источник: https://stackoverflow.com/questions/604 ... etermine-w

Вернуться в «JAVA»