6

In my spring boot aws-cloud SNS http end point confirm subscription is not working. When SNS confirmation comes following error coming in my application. Error :

[Request processing failed; nested exception is java.lang.IllegalArgumentException: Invoked method public abstract void org.springframework.cloud.aws.messaging.endpoint.NotificationStatus.confirmSubscription() is no accessor method!] with root cause
 java.lang.IllegalArgumentException: Invoked method public abstract void org.springframework.cloud.aws.messaging.endpoint.NotificationStatus.confirmSubscription() is no accessor method!
 at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
 at org.spring

My controller handler is :

 @NotificationSubscriptionMapping
 public void handleSubscriptionMessage( NotificationStatus status) throws IOException {
 //Confirming SNS subscription
 status.confirmSubscription();
 }

My Pom contains following :

 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-aws-messaging</artifactId>
 <version>1.0.4.RELEASE</version>
 </dependency>
 <!-- For Spring AWS autoconfiguration-->
 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-aws-autoconfigure</artifactId>
 <version>1.0.4.RELEASE</version>
 </dependency>

I followed the explanation in this link

asked Mar 16, 2016 at 15:57

3 Answers 3

2

Did you specify the custom resolver:

<mvc:annotation-driven>
 <mvc:argument-resolvers>
 <ref bean="notificationResolver" />
 </mvc:argument-resolvers>
</mvc:annotation-driven>
<aws-messaging:notification-argument-resolver id="notificationResolver" />

Also, I cannot see the controller mapping, but in tutorial there is a statement:

Currently it is not possible to define the mapping URL on the method level therefore the RequestMapping must be done at type level and must contain the full path of the endpoint.

answered Mar 16, 2016 at 16:55
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks @m.aibin .... I am doing this using spring boot. Will the 'spring-cloud-autoconfigure' handle this ? Controller mapping I defined on class level. It is working fine as the request comes to handleSubscriptionMessage method.
I didn't specify custom resolver. How can I do this in java config way ? As I am using spring boot.
Hi. I have managed to add this using xml itself as the java config way has some issue while overriding request resolvers.But now I get some error while confirming request. Where/How should I configure the topic ARN in spring aws cloud ? I could not find anything on the tutorial though.
My issue got resolved. Resolver worked perfect. Another issue was that I dint configure region.
|
2

Putting this out for anyone who is after java config for this. Please note you have to use NotificationMessageHandlerMethodArgumentResolver which implements HandlerMethodArgumentResolver.

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.aws.messaging.endpoint.NotificationMessageHandlerMethodArgumentResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
 @Autowired
 private NotificationMessageHandlerMethodArgumentResolver notificationResolver;
 @Override
 public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
 argumentResolvers.add(notificationMessageHandlerMethodArgumentResolver());
 }
 @Bean
 public NotificationMessageHandlerMethodArgumentResolver notificationMessageHandlerMethodArgumentResolver () {
 return new NotificationMessageHandlerMethodArgumentResolver();
 };
}
answered Sep 15, 2017 at 6:03

Comments

0

My Kotlin Configuration looks like this, to configure the subscription and messaging and un-subscription method argument resolving

 import com.amazonaws.services.sns.AmazonSNS
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.cloud.aws.messaging.endpoint.config.NotificationHandlerMethodArgumentResolverConfigurationUtils
 import org.springframework.context.annotation.Configuration
 import org.springframework.web.method.support.HandlerMethodArgumentResolver
 import org.springframework.web.servlet.config.annotation.EnableWebMvc
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
 
 @Configuration
 @EnableWebMvc
 class ListenerWebConfiguration : WebMvcConfigurer
 {
 @Autowired
 private lateinit var amazonSNS: AmazonSNS
 
 override fun addArgumentResolvers(argumentResolvers: MutableList<HandlerMethodArgumentResolver>) {
argumentResolvers.add(NotificationHandlerMethodArgumentResolverConfigurationUtils.getNotificationHandlerMethodArgumentResolver(amazonSNS))
 }
 }
answered May 16, 2021 at 15:47

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.