i want to make an subscriber from my java spring cloud app , this is my receiver class:
@Controller
@RequiredArgsConstructor
@RequestMapping("/mytopic1")
@RestController
public class PurchaseTransactionsSubscriberController {
Logger logger = LoggerFactory.getLogger(PurchaseTransactionsSubscriberController.class);
@NotificationSubscriptionMapping
public void handleSubscriptionMessage(NotificationStatus status) {
logger.info("Received subscription request!");
status.confirmSubscription();
logger.info("Subscription confirmed!");
}
@NotificationUnsubscribeConfirmationMapping
public void handleUnsubscribeMessage(NotificationStatus status) {
logger.info("Received unsubscription request!");
status.confirmSubscription();
logger.info("Unsubscription confirmed!");
}
@NotificationMessageMapping
public void handleNotificationMessage(@NotificationSubject String subject, @NotificationMessage String message) {
logger.info(message);
}
}
my application.yaml
aws:
region: eu-west-2
access-key: acesskey
secret-key: secretkey
sns-endpoint: endpoint that i paste in endpoint section when i made subscription in aws console
@Configuration
public class AWSConfig implements WebMvcConfigurer {
@Value("${aws.region}")
private String awsRegion;
@Value("${aws.access-key}")
private String awsAccessKey;
@Value("${aws.secret-key}")
private String awsSecretKey;
@Value("${aws.sns-endpoint}")
private String snsEndpoint;
@Bean
public AWSCredentials credentials() {
return new BasicAWSCredentials(awsAccessKey, awsSecretKey);
}
@Bean
public AmazonSNS amazonSNS() {
return AmazonSNSClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials()))
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(snsEndpoint, awsRegion))
.build();
}
@Bean
public NotificationStatusHandlerMethodArgumentResolver notificationStatusHandlerMethodArgumentResolver() {
return new NotificationStatusHandlerMethodArgumentResolver(amazonSNS());
}
@Bean
public NotificationHandlerMethodArgumentResolverFactoryBean notificationHandlerMethodArgumentResolverFactoryBean() {
return new NotificationHandlerMethodArgumentResolverFactoryBean(amazonSNS());
}
@Override
@SneakyThrows
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(notificationStatusHandlerMethodArgumentResolver());
try {
resolvers.add(notificationHandlerMethodArgumentResolverFactoryBean().getObject());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
But when i make an subscription the error i receive in backend is this: enter image description here Do you guys have some ideas why it gives me this error? The subscription has the pending confirmation so it did not work