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


Java PubSubException类代码示例

本文整理汇总了Java中com.google.cloud.pubsub.PubSubException的典型用法代码示例。如果您正苦于以下问题:Java PubSubException类的具体用法?Java PubSubException怎么用?Java PubSubException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: declareSubscription

import com.google.cloud.pubsub.PubSubException; //导入依赖的package包/类
/**
 * Declares a subscription and returns its SubscriptionInfo
 * @param topic
 * @param name
 * @return
 */
public SubscriptionInfo declareSubscription(String topic, String name, String group) {
	SubscriptionInfo subscription = null;
	String subscriptionName = createSubscriptionName(name, group);
	try {
		logger.debug("Creating subscription: {} binding to topic : {}",subscriptionName,topic);
		subscription = client.create(
				SubscriptionInfo.of(topic, subscriptionName));
	}
	catch (PubSubException e) {
		if (e.reason().equals(PubSubBinder.ALREADY_EXISTS)) {
			logger.warn("Subscription: {} already exists, reusing definition from remote server",subscriptionName);
			subscription = Subscription.of(topic, subscriptionName);
		}
	}
	return subscription;
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:23,代码来源:PubSubResourceManager.java

示例2: declareTopic

import com.google.cloud.pubsub.PubSubException; //导入依赖的package包/类
public TopicInfo declareTopic(String name, String prefix, Integer partitionIndex) {
	TopicInfo topic = null;

	String topicName = createTopicName(name, prefix, partitionIndex);
	try {
		logger.debug("Creating topic: {} ",topic);
		topic = client.create(TopicInfo.of(topicName));
	}
	catch (PubSubException e) {
		if (e.reason().equals(PubSubBinder.ALREADY_EXISTS)) {
			logger.warn("Topic: {} already exists, reusing definition from remote server",topicName);
			topic = Topic.of(topicName);
		}
	}

	return topic;
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:18,代码来源:PubSubResourceManager.java

示例3: createSubscription

import com.google.cloud.pubsub.PubSubException; //导入依赖的package包/类
public Subscription createSubscription(SubscriptionInfo subscriptionInfo) {
	Subscription subscription = null;
	try {
		subscription = client.create(subscriptionInfo);
	}
	catch (PubSubException e) {
		if (e.reason().equals(PubSubBinder.ALREADY_EXISTS)) {
			subscription = client.getSubscription(subscriptionInfo.name());
		}
		else {
			throw e;
		}
	}
	return subscription;
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:16,代码来源:PubSubResourceManager.java


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