@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * * * <pre> * The messages in the request will be published on this topic. * Format is `projects/{project}/topics/{topic}`. * </pre> * * <code>string topic = 1;</code> */ public Builder clearTopic() { topic_ = getDefaultInstance().getTopic(); onChanged(); return this; } /**
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + TOPIC_FIELD_NUMBER; hash = (53 * hash) + getTopic().hashCode(); if (getMessagesCount() > 0) { hash = (37 * hash) + MESSAGES_FIELD_NUMBER; hash = (53 * hash) + getMessagesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.pubsub.v1.PublishRequest)) { return super.equals(obj); } com.google.pubsub.v1.PublishRequest other = (com.google.pubsub.v1.PublishRequest) obj; boolean result = true; result = result && getTopic().equals(other.getTopic()); result = result && getMessagesList().equals(other.getMessagesList()); 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) + getDescriptorForType().hashCode(); hash = (37 * hash) + TOPIC_FIELD_NUMBER; hash = (53 * hash) + getTopic().hashCode(); if (getMessagesCount() > 0) { hash = (37 * hash) + MESSAGES_FIELD_NUMBER; hash = (53 * hash) + getMessagesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public com.google.pubsub.v1.PublishRequest getDefaultInstanceForType() { return com.google.pubsub.v1.PublishRequest.getDefaultInstance(); }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getTopicBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); } for (int i = 0; i < messages_.size(); i++) { output.writeMessage(2, messages_.get(i)); } unknownFields.writeTo(output); }
public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); }
@Override public long countElements(PublishRequest request) { return request.getMessagesCount(); }
@Override public PartitionKey getBatchPartitionKey(PublishRequest request) { return new PartitionKey(request.getTopic()); }
@java.lang.Override public com.google.pubsub.v1.PublishRequest build() { com.google.pubsub.v1.PublishRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@java.lang.Override public com.google.pubsub.v1.PublishRequest buildPartial() { com.google.pubsub.v1.PublishRequest result = new com.google.pubsub.v1.PublishRequest(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; result.topic_ = topic_; if (messagesBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002)) { messages_ = java.util.Collections.unmodifiableList(messages_); bitField0_ = (bitField0_ & ~0x00000002); } result.messages_ = messages_; } else { result.messages_ = messagesBuilder_.build(); } result.bitField0_ = to_bitField0_; onBuilt(); return result; }
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { done = true; makeExtensionsImmutable();
messages_ = java.util.Collections.unmodifiableList(messages_); makeExtensionsImmutable();
@Test @SuppressWarnings("all") public void publishTest() { String messageIdsElement = "messageIdsElement-744837059"; List<String> messageIds = Arrays.asList(messageIdsElement); PublishResponse expectedResponse = PublishResponse.newBuilder().addAllMessageIds(messageIds).build(); mockPublisher.addResponse(expectedResponse); ProjectTopicName topic = ProjectTopicName.of("[PROJECT]", "[TOPIC]"); ByteString data = ByteString.copyFromUtf8("-86"); PubsubMessage messagesElement = PubsubMessage.newBuilder().setData(data).build(); List<PubsubMessage> messages = Arrays.asList(messagesElement); PublishResponse actualResponse = client.publish(topic, messages); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockPublisher.getRequests(); Assert.assertEquals(1, actualRequests.size()); PublishRequest actualRequest = (PublishRequest) actualRequests.get(0); Assert.assertEquals(topic, ProjectTopicName.parse(actualRequest.getTopic())); Assert.assertEquals(messages, actualRequest.getMessagesList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
.setRequestMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.pubsub.v1.PublishRequest.getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller(
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getTopicBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); } for (int i = 0; i < messages_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, messages_.get(i)); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
public static Builder newBuilder(com.google.pubsub.v1.PublishRequest prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); }
@Test public void testPublishByNumBatchedMessages() throws Exception { Publisher publisher = getTestPublisherBuilder() .setBatchingSettings( Publisher.Builder.DEFAULT_BATCHING_SETTINGS .toBuilder() .setElementCountThreshold(2L) .setDelayThreshold(Duration.ofSeconds(100)) .build()) .build(); testPublisherServiceImpl .addPublishResponse(PublishResponse.newBuilder().addMessageIds("1").addMessageIds("2")) .addPublishResponse(PublishResponse.newBuilder().addMessageIds("3").addMessageIds("4")); ApiFuture<String> publishFuture1 = sendTestMessage(publisher, "A"); ApiFuture<String> publishFuture2 = sendTestMessage(publisher, "B"); ApiFuture<String> publishFuture3 = sendTestMessage(publisher, "C"); // Note we are not advancing time but message should still get published assertEquals("1", publishFuture1.get()); assertEquals("2", publishFuture2.get()); assertFalse(publishFuture3.isDone()); ApiFuture<String> publishFuture4 = publisher.publish(PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("D")).build()); assertEquals("3", publishFuture3.get()); assertEquals("4", publishFuture4.get()); assertEquals(2, testPublisherServiceImpl.getCapturedRequests().get(0).getMessagesCount()); assertEquals(2, testPublisherServiceImpl.getCapturedRequests().get(1).getMessagesCount()); publisher.shutdown(); publisher.awaitTermination(1, TimeUnit.MINUTES); }
public com.google.pubsub.v1.PublishRequest build() { com.google.pubsub.v1.PublishRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }