AWS DynamoDB trigger using Lambda in JAVA

前端 未结 5 1772
天命终不由人
天命终不由人 2021-01-12 13:44

I am trying to trigger an AWS lambda function written in Java, on dynamodb stream events. Amazon has a guide for the same, using NodeJS here http://docs.aws.amazon.com/lambd

5条回答
  •  伪装坚强ぢ
    2021-01-12 14:11

    To obtain the deserialized objects from event handler : 1) In the handler get json from input stream using something like this :

    private String getJsonFrom(InputStream stream) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int letter;
        while ((letter = stream.read()) != -1)
            baos.write(letter);
    
        return new String(baos.toByteArray());
    }
    

    2) Then create a specific deserializer derialize the object from json. 'NewImage' in case of DynamoDB event. One example here.

提交回复
热议问题