[英]Java type for AWS SNS message from SQS
I have a AWS SQS queue subscribed to a SNS topic.我有一个订阅了 SNS 主题的 AWS SQS 队列。 Message I receive from SQS queue looks like this:我从 SQS 队列收到的消息如下所示:
Message body: {
"Type" : "Notification",
"MessageId" : "6ffbe51a-5c00-51f8-a67e-b468ad721131",
"TopicArn" : "arn:aws:sns:eu-central-1:447379608829:dev_com_pio_admin_package",
"Message" : "CUSTOM_JSON_OBJECT",
"Timestamp" : "2017-04-20T17:26:10.410Z",
"SignatureVersion" : "1",
"Signature" : "iLDcSwI5CJ.....==",
"SigningCertURL" : "https://sns.eu-central-1.amazonaws.com/...............",
"UnsubscribeURL" : "https://sns.eu-central-1.amazonaws.com/..............."
}
Is there a Java representing this kind of message in Spring Cloud AWS
or in AWS java SDK
?在Spring Cloud AWS
或AWS java SDK
是否有代表这种消息的AWS java SDK
?
使用对象中的@NotificationMessage 注释(表示消息)作为监听器。
@SqsListener("spring-boot-sqs")
public void getProductoFromSQS(String snsMessageJsonFormat) {
Gson gson = new Gson();
SNSMessage snsMessage = gson.fromJson(snsMessageJsonFormat, SNSMessage.class);
Producto producto = gson.fromJson(snsMessage.getMessage(), Producto.class);
itemservice.save(producto);
}
@Getter
@Setter
public class SNSMessage {
private String Type;
private String MessageId;
private String TopicArn;
private String Message;
}
how you can see you need to model Java Class SNSMessage您如何看到您需要对 Java 类 SNSMessage 进行建模
get the String Message and convert to appropriate Object with Gson.获取字符串消息并使用 Gson 转换为适当的对象。 :) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.