@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
public Builder mergeFrom(com.google.pubsub.v1.PullRequest other) { if (other == com.google.pubsub.v1.PullRequest.getDefaultInstance()) return this; if (!other.getSubscription().isEmpty()) { subscription_ = other.subscription_; onChanged(); } if (other.getReturnImmediately() != false) { setReturnImmediately(other.getReturnImmediately()); } if (other.getMaxMessages() != 0) { setMaxMessages(other.getMaxMessages()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public com.google.pubsub.v1.PullRequest buildPartial() { com.google.pubsub.v1.PullRequest result = new com.google.pubsub.v1.PullRequest(this); result.subscription_ = subscription_; result.returnImmediately_ = returnImmediately_; result.maxMessages_ = maxMessages_; onBuilt(); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.pubsub.v1.PullRequest)) { return super.equals(obj); } com.google.pubsub.v1.PullRequest other = (com.google.pubsub.v1.PullRequest) obj; boolean result = true; result = result && getSubscription().equals(other.getSubscription()); result = result && (getReturnImmediately() == other.getReturnImmediately()); result = result && (getMaxMessages() == other.getMaxMessages()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + SUBSCRIPTION_FIELD_NUMBER; hash = (53 * hash) + getSubscription().hashCode(); hash = (37 * hash) + RETURN_IMMEDIATELY_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getReturnImmediately()); hash = (37 * hash) + MAX_MESSAGES_FIELD_NUMBER; hash = (53 * hash) + getMaxMessages(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The subscription from which messages should be pulled. * Format is `projects/{project}/subscriptions/{sub}`. * </pre> * * <code>string subscription = 1;</code> */ public Builder clearSubscription() { subscription_ = getDefaultInstance().getSubscription(); onChanged(); return this; } /**
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (37 * hash) + SUBSCRIPTION_FIELD_NUMBER; hash = (53 * hash) + getSubscription().hashCode(); hash = (37 * hash) + RETURN_IMMEDIATELY_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( getReturnImmediately()); hash = (37 * hash) + MAX_MESSAGES_FIELD_NUMBER; hash = (53 * hash) + getMaxMessages(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public com.google.pubsub.v1.PullRequest getDefaultInstanceForType() { return com.google.pubsub.v1.PullRequest.getDefaultInstance(); }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getSubscriptionBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, subscription_); } if (returnImmediately_ != false) { output.writeBool(2, returnImmediately_); } if (maxMessages_ != 0) { output.writeInt32(3, maxMessages_); } unknownFields.writeTo(output); }
/** * Pulls messages synchronously, on demand, using the pull request in argument. * * @param pullRequest pull request containing the subscription name * @return the list of {@link AcknowledgeablePubsubMessage} containing the ack ID, subscription * and acknowledger */ private List<AcknowledgeablePubsubMessage> pull(PullRequest pullRequest) { Assert.notNull(pullRequest, "The pull request can't be null."); PullResponse pullResponse = this.subscriberStub.pullCallable().call(pullRequest); return pullResponse.getReceivedMessagesList().stream() .map((message) -> new PulledAcknowledgeablePubsubMessage( ProjectSubscriptionName.of( this.subscriberFactory.getProjectId(), pullRequest.getSubscription()), message.getMessage(), message.getAckId())) .collect(Collectors.toList()); }
@java.lang.Override public com.google.pubsub.v1.PullRequest build() { com.google.pubsub.v1.PullRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@Test @SuppressWarnings("all") public void pullTest() { PullResponse expectedResponse = PullResponse.newBuilder().build(); mockSubscriber.addResponse(expectedResponse); ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); boolean returnImmediately = false; int maxMessages = 496131527; PullResponse actualResponse = client.pull(subscription, returnImmediately, maxMessages); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests(); Assert.assertEquals(1, actualRequests.size()); PullRequest actualRequest = (PullRequest) actualRequests.get(0); Assert.assertEquals( subscription, ProjectSubscriptionName.parse(actualRequest.getSubscription())); Assert.assertEquals(returnImmediately, actualRequest.getReturnImmediately()); Assert.assertEquals(maxMessages, actualRequest.getMaxMessages()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + SUBSCRIPTION_FIELD_NUMBER; hash = (53 * hash) + getSubscription().hashCode(); hash = (37 * hash) + RETURN_IMMEDIATELY_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getReturnImmediately()); hash = (37 * hash) + MAX_MESSAGES_FIELD_NUMBER; hash = (53 * hash) + getMaxMessages(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * <pre> * The subscription from which messages should be pulled. * </pre> * * <code>optional string subscription = 1;</code> */ public Builder clearSubscription() { subscription_ = getDefaultInstance().getSubscription(); onChanged(); return this; } /**
private static io.grpc.MethodDescriptor< com.google.pubsub.v1.PullRequest, com.google.pubsub.v1.PullResponse> getPullMethodHelper() { io.grpc.MethodDescriptor<com.google.pubsub.v1.PullRequest, com.google.pubsub.v1.PullResponse> getPullMethod; if ((getPullMethod = SubscriberGrpc.getPullMethod) == null) { synchronized (SubscriberGrpc.class) { if ((getPullMethod = SubscriberGrpc.getPullMethod) == null) { SubscriberGrpc.getPullMethod = getPullMethod = io.grpc.MethodDescriptor .<com.google.pubsub.v1.PullRequest, com.google.pubsub.v1.PullResponse> newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName( generateFullMethodName("google.pubsub.v1.Subscriber", "Pull")) .setSampledToLocalTracing(true) .setRequestMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.pubsub.v1.PullRequest.getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.pubsub.v1.PullResponse.getDefaultInstance())) .setSchemaDescriptor(new SubscriberMethodDescriptorSupplier("Pull")) .build(); } } } return getPullMethod; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getSubscriptionBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, subscription_); } if (returnImmediately_ != false) { size += com.google.protobuf.CodedOutputStream.computeBoolSize(2, returnImmediately_); } if (maxMessages_ != 0) { size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, maxMessages_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
/** * Pulls messages synchronously, on demand, using the pull request in argument. * * @param pullRequest pull request containing the subscription name * @return the list of {@link AcknowledgeablePubsubMessage} containing the ack ID, subscription * and acknowledger */ private List<AcknowledgeablePubsubMessage> pull(PullRequest pullRequest) { Assert.notNull(pullRequest, "The pull request can't be null."); PullResponse pullResponse = this.subscriberStub.pullCallable().call(pullRequest); return pullResponse.getReceivedMessagesList().stream() .map((message) -> new PulledAcknowledgeablePubsubMessage( ProjectSubscriptionName.of( this.subscriberFactory.getProjectId(), pullRequest.getSubscription()), message.getMessage(), message.getAckId())) .collect(Collectors.toList()); }
public com.google.pubsub.v1.PullRequest build() { com.google.pubsub.v1.PullRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
PullRequest.newBuilder() .setSubscription(subscription) .setReturnImmediately(returnImmediately)
public Builder mergeFrom(com.google.pubsub.v1.PullRequest other) { if (other == com.google.pubsub.v1.PullRequest.getDefaultInstance()) return this; if (!other.getSubscription().isEmpty()) { subscription_ = other.subscription_; onChanged(); } if (other.getReturnImmediately() != false) { setReturnImmediately(other.getReturnImmediately()); } if (other.getMaxMessages() != 0) { setMaxMessages(other.getMaxMessages()); } onChanged(); return this; }