我得到的例外:
2021-06-16 05:28:57.497 ERROR 2751 --- [nio-8081-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: @NotificationMessage annotated parameters are only allowed for method that receive a notification message.] with root cause
java.lang.IllegalArgumentException: @NotificationMessage annotated parameters are only allowed for method that receive a notification message.
at org.springframework.cloud.aws.messaging.endpoint.NotificationSubjectHandlerMethodArgumentResolver.doResolverArgumentFromNotificationMessage(NotificationSubjectHandlerMethodArgumentResolver.java:39) ~[spring-cloud-aws-messaging-1.0.0.RELEASE.jar!/:1.0.0.RELEASE]
at org.springframework.cloud.aws.messaging.endpoint.AbstractNotificationMessageHandlerMethodArgumentResolver.resolveArgument(AbstractNotificationMessageHandlerMethodArgumentResolver.java:49) ~[spring-cloud-aws-messaging-1.0.0.RELEASE.jar!/:1.0.0.RELEASE]
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) ~[spring-web-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
Run Code Online (Sandbox Code Playgroud)
主题订阅成功。
应该处理消息的方法代码(Java SpringCloud)
@NotificationMessageMapping
public void handleNotificationMessage(@NotificationSubject String subject, @NotificationMessage String message) {
System.out.println("in …Run Code Online (Sandbox Code Playgroud)