I am trying to develop an AWS Lambda function that is triggered by events from SQS.
I am using the spring-cloud-function-adapter-aws (version 1.0.0.RELEASE) and in specifically a SpringBootRequestHandler.
However, the ObjectMapper that is being used is case-sensitive and therefore failing to successful convert the Json coming from SQS.
SQS publishes the following Json and it is the Records field in particular that I'm having the problem with.
{
"Records": [
{
"body": "Hello from SQS!",
"receiptHandle": "MessageReceiptHandle",
"md5OfBody": "7b270e59b47ff90a553787216d55d91d",
"eventSourceARN": "arn:aws:sqs:eu-west-1:123456789012:MyQueue",
"eventSource": "aws:sqs",
"awsRegion": "eu-west-1",
"messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
"attributes": {
"ApproximateFirstReceiveTimestamp": "1523232000001",
"SenderId": "123456789012",
"ApproximateReceiveCount": "1",
"SentTimestamp": "1523232000000"
},
"messageAttributes": {}
}
]
}
I have tried the suggestions in this question, but to no avail. Configuring ObjectMapper in Spring
In my POJO, I've also added the below annotation but it isn't working either whilst it would outside of Lambda.
@JsonProperty("Records")
private List<SqsRecord> Records;
Any help would be much appreciated.
My Lambda handler is defined as:
public class SqsEventHandler extends SpringBootRequestHandler<SqsEvent, String> {}
The POJO defined as:
public class SqsEvent {
@JsonProperty("Records")
private List<SqsRecord> records;
@Data
public class SqsRecord {
private String body;
private String receiptHandle;
private String md5OfBody;
private String eventSourceARN;
private String eventSource;
private String awsRegion;
private String messageId;
}
}
I expect the Json from the sample message to be able to be read in by the ObjectMapper, but the field "records" is null.