未正确分析java SNS消息属性
我从AWS控制台发送带有以下消息属性的SNS消息:
Type: String
Name: is_data
Value: false
SNS由SQS接收,并在Lambda函数中解析
SQS消息正文包含以下字段:
"MessageAttributes": {
"is_data": {
"Type": "String",
"Value": "false"
}
但是,当我尝试解析它时,它会抛出错误:
void f(SQSMessage sqsMessage) {
String messageBody = sqsMessage.getBody();
JsonNode body = objectMapper.readTree(messageBody);
Map<String, SNSEvent.MessageAttribute> messageAttributeMap =
objectMapper.convertValue(body.get("MessageAttributes"),
new TypeReference<Map<String, SNSEvent.MessageAttribute>>(){});
}
Caused by: java.lang.IllegalArgumentException: Unrecognized field "Type" (class com.amazonaws.services.lambda.runtime.events.SNSEvent$MessageAttribute), not marked as ignorable (2 known properties: "value", "type"])
我错过了什么
为什么SNS发送“Type”和“Vvalue”,而类需要“type”和“value”
共 (0) 个答案