Я пытаюсь создать клиентский компонент SNS.
<bean id="snsClientBuilder" class="com.amazonaws.services.sns.AmazonSNSClientBuilder"
factory-method="standard">
<property name="credentials" ref="credntialsPair" />
<property name="region" value="us-west-2" />
</bean>
<bean id="snsClient" factory-bean="snsClientBuilder" factory-method="build"/>
/>
Код
@Autowired
private AmazonSNSClientBuilder snsClientBuilder;
@Autowired
private AmazonSNS snsClient;
@Autowired
private String notificationTopicArn; //Bean also correctly defined
@Override
public void sendNotification(final Notification notification) {
final String message = notification.toJson();
//wrapped in a try catch
snsClient.publish(new PublishRequest().withMessage(message).withTopicArn(notificationTopicArn));
}
Этот вызов sns завершается ошибкой
Invalid parameter: TopicArn (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: f320367c-774d-55c0-8b1b-609005851d6c)
Я знаю проблема в том, что у клиента sns неправильный регион, потому что, если я делаю это.
@Override
public void sendNotification(final Notification notification) {
final String message = notification.toJson();
//works, but i dont want to set the region everytime
snsClient.setRegion(Region.getRegion(Regions.US_WEST_2));
//wrapped in a try catch
snsClient.publish(new PublishRequest().withMessage(message).withTopicArn(notificationTopicArn));
}
Это работает. Также, если я сделаю это.
@Override
public void sendNotification(final Notification notification) {
final String message = notification.toJson();
//works, but i want this built as a bean
snsClient = snsClientBuilder.build()
//wrapped in a try catch
snsClient.publish(new PublishRequest().withMessage(message).withTopicArn(notificationTopicArn));
}
Похоже, эта строка <bean id="snsClient" factory-bean="snsClientBuilder" factory-method="build"/>
просто не работает. Есть идеи?