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


Java RetrySettings类代码示例

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


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

示例1: createSubscriberStub

import com.google.api.gax.retrying.RetrySettings; //导入依赖的package包/类
@Override
public SubscriberStub createSubscriberStub(RetrySettings retrySettings) {
	SubscriptionAdminSettings.Builder subscriptionAdminSettingsBuilder =
			SubscriptionAdminSettings.newBuilder();

	if (this.credentialsProvider != null) {
		subscriptionAdminSettingsBuilder.setCredentialsProvider(this.credentialsProvider);
	}

	if (this.pullEndpoint != null) {
		subscriptionAdminSettingsBuilder.setEndpoint(this.pullEndpoint);
	}

	if (this.executorProvider != null) {
		subscriptionAdminSettingsBuilder.setExecutorProvider(this.executorProvider);
	}

	if (this.headerProvider != null) {
		subscriptionAdminSettingsBuilder.setHeaderProvider(this.headerProvider);
	}

	if (this.channelProvider != null) {
		subscriptionAdminSettingsBuilder.setTransportChannelProvider(this.channelProvider);
	}

	if (this.apiClock != null) {
		subscriptionAdminSettingsBuilder.setClock(this.apiClock);
	}

	if (retrySettings != null) {
		subscriptionAdminSettingsBuilder.pullSettings().setRetrySettings(retrySettings);
	}

	try {
		return GrpcSubscriberStub.create(subscriptionAdminSettingsBuilder.build());
	}
	catch (IOException e) {
		throw new RuntimeException("Error creating the SubscriberStub", e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:41,代码来源:DefaultSubscriberFactory.java

示例2: pull

import com.google.api.gax.retrying.RetrySettings; //导入依赖的package包/类
/**
 * Pulls messages synchronously, on demand, using the pull request in argument.
 *
 * <p>
 * This method acknowledges all received messages.
 * @param pullRequest pull request containing the subscription name
 * @return the list of {@link PubsubMessage} containing the headers and payload
 */
private List<PubsubMessage> pull(PullRequest pullRequest, RetrySettings retrySettings) {
	Assert.notNull(pullRequest, "The pull request cannot be null.");

	try {
		SubscriberStub subscriber = this.subscriberFactory.createSubscriberStub(retrySettings);
		Assert.notNull(subscriber, "A SubscriberStub is needed to execute the pull request.");

		PullResponse pullResponse =	subscriber.pullCallable().call(pullRequest);

		// Ack received messages.
		if (pullResponse.getReceivedMessagesCount() > 0) {
			List<String> ackIds = pullResponse.getReceivedMessagesList().stream()
					.map(ReceivedMessage::getAckId)
					.collect(Collectors.toList());

			AcknowledgeRequest acknowledgeRequest = AcknowledgeRequest.newBuilder()
					.setSubscriptionWithSubscriptionName(
							pullRequest.getSubscriptionAsSubscriptionName())
					.addAllAckIds(ackIds)
					.build();

			subscriber.acknowledgeCallable().call(acknowledgeRequest);
		}

		return pullResponse.getReceivedMessagesList().stream()
				.map(ReceivedMessage::getMessage)
				.collect(Collectors.toList());
	}
	catch (Exception ioe) {
		throw new PubSubException("Error pulling messages from subscription "
				+ pullRequest.getSubscription() + ".", ioe);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:42,代码来源:PubSubTemplate.java

示例3: setRetrySettings

import com.google.api.gax.retrying.RetrySettings; //导入依赖的package包/类
/**
 * Set the API call retry configuration.
 */
public void setRetrySettings(RetrySettings retrySettings) {
	this.retrySettings = retrySettings;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:7,代码来源:DefaultPublisherFactory.java

示例4: createSubscriberStub

import com.google.api.gax.retrying.RetrySettings; //导入依赖的package包/类
/**
 * Create a {@link SubscriberStub} that is needed to execute {@link PullRequest}s.
 * @param retrySettings parameters for retrying pull requests when they fail, including
 * jitter logic, timeout, and exponential backoff
 * @return the {@link SubscriberStub} used for executing {@link PullRequest}s
 */
SubscriberStub createSubscriberStub(RetrySettings retrySettings);
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:8,代码来源:SubscriberFactory.java

示例5: pull

import com.google.api.gax.retrying.RetrySettings; //导入依赖的package包/类
/**
 * Pull and auto-acknowledge a number of messages from a Google Cloud Pub/Sub subscription.
 * @param subscription the subscription name
 * @param maxMessages the maximum number of pulled messages
 * @param returnImmediately returns immediately even if subscription doesn't contain enough
 * messages to satisfy {@code maxMessages}
 * @param retrySettings the timeout and retry setting for the pull request
 * @return the list of received messages
 */
List<PubsubMessage> pull(String subscription, Integer maxMessages,
		Boolean returnImmediately, RetrySettings retrySettings);
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:12,代码来源:PubSubOperations.java


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