Я пытаюсь отправить уведомление в SNS-Topic в aws, используя spring boot и spring-cloud-aws-messaging. Моя конфигурация AWS выглядит следующим образом -:
@Bean
public AmazonSNS amazonSNS(){
if(Objects.nonNull(snsClient)){
final AWSCredentials awsCredentials = new BasicAWSCredentials(awsConfig.getAccessKey(),
awsConfig.getSecretKey());
snsClient = AmazonSNSClientBuilder.standard()
.withRegion(awsConfig.getRegion())
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.build();
}
return snsClient;
}
@Bean
public NotificationMessagingTemplate notificationMessagingTemplate(){
return new NotificationMessagingTemplate(amazonSNS());
}
И мой код контроллера покоя выглядит следующим образом
@Autowired
NotificationMessagingTemplate messagingTemplate;
@GetMapping("/postMessage")
public void sendMessage(){
System.out.println("Sending Message");
messagingTemplate.sendNotification("example-topic-arn", "Test Message","Test Subject");
}
Я получаю это исключение -:
[Request processing failed; nested exception is org.springframework.messaging.MessageDeliveryException: Failed to send message to TopicMessageChannel[TopicMessageChannel@2a7a4044]; nested exception is java.lang.NullPointerException, failedMessage=GenericMessage [payload=Test Message, headers={NOTIFICATION_SUBJECT_HEADER=Test Message, id=96817d20-fb5d-7e07-76e2-e3492986df0b, contentType=text/plain;charset=UTF-8, timestamp=1573384357842}]] with root cause
Я новичок в AWS, пожалуйста, помогите.