You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When using SNS, I usually configure the SNS ARN using @ConfigurationProperties and pass it when using the SnsTemplate class. If an incorrect ARN is configured, the exception is thrown at runtime when the library tries to publish a message. To allow validation of SNS topic existence to be performed at application startup using ConstraintValidator, It would be great if a method boolean topicExists(String topicArn) is available in SnsTemplate class. This would be similar to the method boolean bucketExists(String bucketName) present in S3Template class.
Describe the solution you'd like
addition of method boolean topicExists(String topicArn) in SnsTemplate. This can be achieved using the read only action sns:ListTopics. Something like below
public boolean topicExists(String topicArn) {
Assert.notNull(topicArn, "topicArn is required");
if (!isValidArnFormat(topicArn)) {
throw SomeException();
}
final var snsTopics = getTopics();
for (var snsTopic : snsTopics) {
if (snsTopic.topicArn().equals(topicArn)) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
private List<Topic> getTopics() {
final var snsTopics = new ArrayList<Topic>();
ListTopicsResponse listTopicsResponse = snsClient.listTopics();
snsTopics.addAll(listTopicsResponse.topics());
while (listTopicsResponse.nextToken() != null) {
var nextToken = listTopicsResponse.nextToken();
listTopicsResponse = snsClient.listTopics(request -> request.nextToken(nextToken));
snsTopics.addAll(listTopicsResponse.topics());
}
return snsTopics;
}
Describe alternatives you've considered
Used the above solution in my application, but it'll be great if there was a concise way of doing this similar to S3Template
Additional context
Can submit PR if the feature is approved
The text was updated successfully, but these errors were encountered:
Type: Feature
Is your feature request related to a problem? Please describe.
When using SNS, I usually configure the SNS ARN using
@ConfigurationProperties
and pass it when using theSnsTemplate
class. If an incorrect ARN is configured, the exception is thrown at runtime when the library tries to publish a message. To allow validation of SNS topic existence to be performed at application startup using ConstraintValidator, It would be great if a methodboolean topicExists(String topicArn)
is available inSnsTemplate
class. This would be similar to the methodboolean bucketExists(String bucketName)
present inS3Template
class.Describe the solution you'd like
addition of method
boolean topicExists(String topicArn)
in SnsTemplate. This can be achieved using the read only actionsns:ListTopics
. Something like belowDescribe alternatives you've considered
Used the above solution in my application, but it'll be great if there was a concise way of doing this similar to
S3Template
Additional context
Can submit PR if the feature is approved
The text was updated successfully, but these errors were encountered: