如何在Spring-cloud-aws框架​​中正确实现SNS接收器?(即@NotificationMessageMapping)

Jai*_*Jai 5 java spring amazon-web-services amazon-sns spring-cloud

我目前正在使用 STS 3.6.3SR1 和 Spring 4.1.4。尝试测试 spring-cloud-aws 在我们的应用程序中使用的可行性。

与问题相关的罐子:

spring-cloud-aws-autoconfigure-1.0.0.RC2.jar

spring-cloud-aws-context-1.0.0.RC2.jar

spring-cloud-aws-core-1.0.0.RC2.jar

spring-cloud-aws-messaging-1.0.0.RC2.jar

使用aws-sdk-1.9.3

目前我的 xml 上下文文件中有这个。

<mvc:annotation-driven>
    <mvc:argument-resolvers>
        <ref bean="notificationResolver"/>
    </mvc:argument-resolvers>
</mvc:annotation-driven> 

<aws-messaging:notification-argument-resolver id="notificationResolver" />


<aws-messaging:notification-messaging-template id="notificationMessagingTemplate" default-destination="snsChannelTopic"/> 
Run Code Online (Sandbox Code Playgroud)

目前已将此控制器类定义为我的端点。

public class AmazonSNSController {
    @Autowired
    HttpServletRequest request;

    @Autowired
    HttpServletResponse response;

    @NotificationSubscriptionMapping
    public void handleSubscriptionMessage(SnsHelper status) throws IOException {
        //We subscribe to start receive the message
        status.setRequest(request);
        status.setResponse(response);
        status.confirmSubscription();
    }

    @NotificationMessageMapping
    public void handleNotificationMessage(@NotificationSubject String subject, @NotificationMessage String message) {
        System.out.println(subject + message);
    }

    @NotificationUnsubscribeConfirmationMapping
    public void handleUnsubscribeMessage(SnsHelper status) {
        //e.g. the client has been unsubscribed and we want to "re-subscribe"
        //status.confirmSubscription();
    }
Run Code Online (Sandbox Code Playgroud)

在上面的类 SnsHelper 中实现了NotificationStatus,并且我已经正确确认了订阅。我也收到了handleNotificationMessage 方法的通知。但是,无论我发送什么,两个字符串的计算结果都为 null。

我相信这与notificationResolver未正确注册/应用有关。

任何人都可以提供一些指导吗?

感谢您的帮助。