本文整理汇总了Java中com.amazonaws.services.sns.model.ListTopicsResult.getNextToken方法的典型用法代码示例。如果您正苦于以下问题:Java ListTopicsResult.getNextToken方法的具体用法?Java ListTopicsResult.getNextToken怎么用?Java ListTopicsResult.getNextToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.sns.model.ListTopicsResult
的用法示例。
在下文中一共展示了ListTopicsResult.getNextToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrCreateNotification
import com.amazonaws.services.sns.model.ListTopicsResult; //导入方法依赖的package包/类
/**
*
* @param email
* @return
*/
public String getOrCreateNotification(String email) {
String ret = null;
String topicName = getTopicName(email);
String nextToken = null;
do {
ListTopicsResult listTopics = asyncSnsClient.listTopics(nextToken);
List<Topic> topics = listTopics.getTopics();
for (Topic s : topics) {
if (s.getTopicArn().endsWith(topicName)) {
ret = s.getTopicArn();
break;
}
}
nextToken = listTopics.getNextToken();
} while (ret == null && nextToken != null);
if (ret == null) {
// create the topic and the subscription
CreateTopicResult topic = asyncSnsClient.createTopic(topicName);
SubscribeRequest req = new SubscribeRequest(topic.getTopicArn(), "email", email);
asyncSnsClient.subscribeAsync(req);
ret = topic.getTopicArn();
}
return ret;
}
示例2: topicsAreReturnedInChunksOf100
import com.amazonaws.services.sns.model.ListTopicsResult; //导入方法依赖的package包/类
@Test
public void topicsAreReturnedInChunksOf100() {
for (int i = 0; i < 120; i++)
sns.createTopic("topic" + i);
ListTopicsResult result = sns.listTopics();
final String token = result.getNextToken();
assertThat(token).isNotNull();
assertThat(arnValues(result.getTopics()))
.hasSize(100)
.contains(
"arn:aws:sns:us-east-1:12345:topic0",
"arn:aws:sns:us-east-1:12345:topic1",
"arn:aws:sns:us-east-1:12345:topic10",
"arn:aws:sns:us-east-1:12345:topic100",
"arn:aws:sns:us-east-1:12345:topic8",
"arn:aws:sns:us-east-1:12345:topic80")
.doesNotContain(
"arn:aws:sns:us-east-1:12345:topic9");
result = sns.listTopics(token);
assertThat(result.getNextToken()).isNull();
assertThat(arnValues(result.getTopics()))
.hasSize(20)
.contains(
"arn:aws:sns:us-east-1:12345:topic81",
"arn:aws:sns:us-east-1:12345:topic9",
"arn:aws:sns:us-east-1:12345:topic90",
"arn:aws:sns:us-east-1:12345:topic99")
.doesNotContain(
"arn:aws:sns:us-east-1:12345:topic120");
}
示例3: topicArnForName
import com.amazonaws.services.sns.model.ListTopicsResult; //导入方法依赖的package包/类
private String topicArnForName(final String name) {
String nextToken = null;
String topicArn = null;
while (topicArn == null) {
final ListTopicsResult listTopicsResult = amazonSnsClient.listTopics(nextToken);
topicArn = topicArnForNameInTopics(name, listTopicsResult.getTopics());
nextToken = listTopicsResult.getNextToken();
if (nextToken == null) {
break;
}
}
return topicArn;
}