public Builder mergeFrom(com.google.pubsub.v1.ReceivedMessage other) { if (other == com.google.pubsub.v1.ReceivedMessage.getDefaultInstance()) return this; if (!other.getAckId().isEmpty()) { ackId_ = other.ackId_; onChanged(); } if (other.hasMessage()) { mergeMessage(other.getMessage()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public com.google.pubsub.v1.ReceivedMessage buildPartial() { com.google.pubsub.v1.ReceivedMessage result = new com.google.pubsub.v1.ReceivedMessage(this); result.ackId_ = ackId_; if (messageBuilder_ == null) { result.message_ = message_; } else { result.message_ = messageBuilder_.build(); } onBuilt(); return result; }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getAckIdBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, ackId_); } if (message_ != null) { output.writeMessage(2, getMessage()); } unknownFields.writeTo(output); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.pubsub.v1.ReceivedMessage)) { return super.equals(obj); } com.google.pubsub.v1.ReceivedMessage other = (com.google.pubsub.v1.ReceivedMessage) obj; boolean result = true; result = result && getAckId().equals(other.getAckId()); result = result && (hasMessage() == other.hasMessage()); if (hasMessage()) { result = result && getMessage().equals(other.getMessage()); } result = result && unknownFields.equals(other.unknownFields); return result; }
/** * * * <pre> * This ID can be used to acknowledge the received message. * </pre> * * <code>string ack_id = 1;</code> */ public Builder clearAckId() { ackId_ = getDefaultInstance().getAckId(); onChanged(); return this; } /**
AckHandler ackHandler = new AckHandler( message.getAckId(), message.getMessage().getSerializedSize(), totalExpiration); if (pendingMessages.putIfAbsent(message.getAckId(), ackHandler) != null) { pendingReceipts.add(message.getAckId());
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ACK_ID_FIELD_NUMBER; hash = (53 * hash) + getAckId().hashCode(); if (hasMessage()) { hash = (37 * hash) + MESSAGE_FIELD_NUMBER; hash = (53 * hash) + getMessage().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
if (message.hasMessage()) { FlowFile flowFile = session.create(); ackIds.add(message.getAckId()); attributes.put(ACK_ID_ATTRIBUTE, message.getAckId()); attributes.put(SERIALIZED_SIZE_ATTRIBUTE, String.valueOf(message.getSerializedSize())); attributes.put(MESSAGE_ID_ATTRIBUTE, message.getMessage().getMessageId()); attributes.put(MSG_ATTRIBUTES_COUNT_ATTRIBUTE, String.valueOf(message.getMessage().getAttributesCount())); attributes.put(MSG_PUBLISH_TIME_ATTRIBUTE, String.valueOf(message.getMessage().getPublishTime().getSeconds())); attributes.putAll(message.getMessage().getAttributesMap()); flowFile = session.write(flowFile, out -> out.write(message.getMessage().getData().toByteArray()));
@Test public void testAck() throws Exception { dispatcher.processReceivedMessages(Collections.singletonList(TEST_MESSAGE), NOOP_RUNNABLE); consumers.take().ack(); dispatcher.processOutstandingAckOperations(); assertThat(sentAcks).contains(TEST_MESSAGE.getAckId()); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (37 * hash) + ACK_ID_FIELD_NUMBER; hash = (53 * hash) + getAckId().hashCode(); if (hasMessage()) { hash = (37 * hash) + MESSAGE_FIELD_NUMBER; hash = (53 * hash) + getMessage().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The message. * </pre> * * <code>.google.pubsub.v1.PubsubMessage message = 2;</code> */ public com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder() { return getMessage(); }
@java.lang.Override public com.google.pubsub.v1.ReceivedMessage getDefaultInstanceForType() { return com.google.pubsub.v1.ReceivedMessage.getDefaultInstance(); }
@java.lang.Override public com.google.pubsub.v1.ReceivedMessage build() { com.google.pubsub.v1.ReceivedMessage result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
/** * 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 boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.pubsub.v1.ReceivedMessage)) { return super.equals(obj); } com.google.pubsub.v1.ReceivedMessage other = (com.google.pubsub.v1.ReceivedMessage) obj; boolean result = true; result = result && getAckId() .equals(other.getAckId()); result = result && (hasMessage() == other.hasMessage()); if (hasMessage()) { result = result && getMessage() .equals(other.getMessage()); } return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ACK_ID_FIELD_NUMBER; hash = (53 * hash) + getAckId().hashCode(); if (hasMessage()) { hash = (37 * hash) + MESSAGE_FIELD_NUMBER; hash = (53 * hash) + getMessage().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getAckIdBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, ackId_); } if (message_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getMessage()); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@Test public void testExtension_Close() throws Exception { dispatcher.processReceivedMessages(Collections.singletonList(TEST_MESSAGE), NOOP_RUNNABLE); dispatcher.extendDeadlines(); assertThat(sentModAcks) .contains(ModAckItem.of(TEST_MESSAGE.getAckId(), Subscriber.MIN_ACK_DEADLINE_SECONDS)); sentModAcks.clear(); // Default total expiration is an hour (60*60 seconds). We normally would extend by 10s. // However, only extend by 5s here, since there's only 5s left before total expiration. clock.advance(60 * 60 - 5, TimeUnit.SECONDS); dispatcher.extendDeadlines(); assertThat(sentModAcks).contains(ModAckItem.of(TEST_MESSAGE.getAckId(), 5)); }
/** * <pre> * This ID can be used to acknowledge the received message. * </pre> * * <code>optional string ack_id = 1;</code> */ public Builder clearAckId() { ackId_ = getDefaultInstance().getAckId(); onChanged(); return this; } /**