當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。