当前位置: 首页>>代码示例>>Java>>正文


Java Topic.getTopicArn方法代码示例

本文整理汇总了Java中com.amazonaws.services.sns.model.Topic.getTopicArn方法的典型用法代码示例。如果您正苦于以下问题:Java Topic.getTopicArn方法的具体用法?Java Topic.getTopicArn怎么用?Java Topic.getTopicArn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.sns.model.Topic的用法示例。


在下文中一共展示了Topic.getTopicArn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOrCreateNotification

import com.amazonaws.services.sns.model.Topic; //导入方法依赖的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;
}
 
开发者ID:intuit,项目名称:Tank,代码行数:31,代码来源:CloudwatchInstance.java

示例2: getTopicARN

import com.amazonaws.services.sns.model.Topic; //导入方法依赖的package包/类
public String getTopicARN() {
	try {
		if (topicANR.isEmpty()) {
			ListTopicsResult topics = snsClient.listTopics();
			for(Topic topic : topics.getTopics()) {
				String foundArn = topic.getTopicArn();
				if (foundArn.contains(TOPIC_NAME)) {
					logger.info("Found notification topic for SNS, ARN is: " + foundArn);
					topicANR =  foundArn;
					break;
				}
			}
		}
		if (topicANR.isEmpty()) {
			logger.info("Did not find notification topic for SNS, to receive updates create topic: " + TOPIC_NAME);
		}
		return topicANR;
	} 
	catch (AuthorizationErrorException authException) {
		logger.error("Did not send SNS notification. You may need to update permissions for user via IAM. Exception was " + authException);
		return "";
	}
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:24,代码来源:SNSNotificationSender.java

示例3: createTopicIfNotExists

import com.amazonaws.services.sns.model.Topic; //导入方法依赖的package包/类
private void createTopicIfNotExists() {
	for (Topic topic : client.listTopics().getTopics()) {
		if (topic.getTopicArn().contains(topicName)) {
			topicArn = topic.getTopicArn();
			break;
		}
	}
	if (topicArn == null) {
		CreateTopicRequest request = new CreateTopicRequest(topicName);
		CreateTopicResult result = client.createTopic(request);
		topicArn = result.getTopicArn();
		log.debug("Topic created, arn: " + topicArn);
	} else {
		log.debug("Topic already created: " + topicArn);
	}
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:17,代码来源:SnsExecutor.java

示例4: getEssTopicArn

import com.amazonaws.services.sns.model.Topic; //导入方法依赖的package包/类
/**
 * Returns ARN of topic where AutoScaling publishes system events
 *
 * @return
 */
private String getEssTopicArn() {
    Topic ess_topic = amazonSNS.listTopics().getTopics()
            .stream().filter(topic -> topic.getTopicArn().endsWith(ESS_TOPIC_NAME)).findFirst()
            .orElseThrow(() -> new ConfigurationException("Topic " + ESS_TOPIC_NAME + " does not exist."));
    return ess_topic.getTopicArn();
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:12,代码来源:ClusterConfigurationServiceImpl.java

示例5: topicArnForNameInTopics

import com.amazonaws.services.sns.model.Topic; //导入方法依赖的package包/类
private String topicArnForNameInTopics(final String name, final List<Topic> topics) {
    final String topicArnSuffix = ":" + name;
    for (final Topic topic : topics) {
        final String topicArn = topic.getTopicArn();
        final int pos = topicArn.lastIndexOf(topicArnSuffix);
        if (pos == -1) {
            continue;
        }
        final String actualName = topicArn.substring(pos + 1);
        if (actualName.equals(name)) {
            return topicArn;
        }
    }
    return null;
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:16,代码来源:DefaultSnsTopicResourceFactory.java

示例6: getTopicResourceName

import com.amazonaws.services.sns.model.Topic; //导入方法依赖的package包/类
private String getTopicResourceName(String marker, String topicName) {
    ListTopicsResult listTopicsResult = this.amazonSns.listTopics(new ListTopicsRequest(marker));
    for (Topic topic : listTopicsResult.getTopics()) {
        AmazonResourceName resourceName = AmazonResourceName.fromString(topic.getTopicArn());
        if (resourceName.getResourceType().equals(topicName)) {
            return topic.getTopicArn();
        }
    }

    if (StringUtils.hasText(listTopicsResult.getNextToken())) {
        return getTopicResourceName(listTopicsResult.getNextToken(), topicName);
    } else {
        throw new IllegalArgumentException("No topic found for name :'" + topicName + "'");
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:16,代码来源:DynamicTopicDestinationResolver.java

示例7: getTopicArn

import com.amazonaws.services.sns.model.Topic; //导入方法依赖的package包/类
public static String getTopicArn( final AmazonSNSClient sns, final String queueName, final boolean createOnMissing )
    throws Exception {

    if ( logger.isTraceEnabled() ) {
        logger.trace( "Looking up Topic ARN: {}", queueName );
    }

    ListTopicsResult listTopicsResult = sns.listTopics();
    String topicArn = null;

    for ( Topic topic : listTopicsResult.getTopics() ) {
        String arn = topic.getTopicArn();

        if ( queueName.equals( arn.substring( arn.lastIndexOf( ':' ) ) ) ) {
            topicArn = arn;

            if (logger.isTraceEnabled()) {
                logger.trace( "Found existing topic arn=[{}] for queue=[{}]", topicArn, queueName );
            }
        }
    }

    if ( topicArn == null && createOnMissing ) {
        if (logger.isTraceEnabled()) {
            logger.trace("Creating topic for queue=[{}]...", queueName);
        }

        CreateTopicResult createTopicResult = sns.createTopic( queueName );
        topicArn = createTopicResult.getTopicArn();

        if (logger.isTraceEnabled()) {
            logger.trace("Successfully created topic with name {} and arn {}", queueName, topicArn);
        }
    }
    else {
        logger.error( "Error looking up topic ARN for queue=[{}] and createOnMissing=[{}]", queueName,
            createOnMissing );
    }

    if ( logger.isTraceEnabled() ) {
        logger.trace( "Returning Topic ARN=[{}] for Queue=[{}]", topicArn, queueName );
    }


    return topicArn;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:47,代码来源:AmazonNotificationUtils.java


注:本文中的com.amazonaws.services.sns.model.Topic.getTopicArn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。