本文整理汇总了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);
}
}
示例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);
}
}
示例3: setRetrySettings
import com.google.api.gax.retrying.RetrySettings; //导入依赖的package包/类
/**
* Set the API call retry configuration.
*/
public void setRetrySettings(RetrySettings retrySettings) {
this.retrySettings = retrySettings;
}
示例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);
示例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);