Skip to content

Commit 364dc70

Browse files
charlesliqlogicchingor13
authored andcommitted
---
yaml --- r: 15031 b: refs/heads/autosynth-bigquerydatatransfer c: 6e2c2dd h: refs/heads/master i: 15029: bf84084 15027: 12130f0 15023: 5fd1d2a
1 parent e41b382 commit 364dc70

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ refs/tags/v0.68.0: 9cc799fcf68c82ab431d425fefa58ef615ce8e5b
124124
refs/tags/v0.69.0: 78f67a29e8b9c46ba01de566a2eae0fd1c03edea
125125
refs/heads/autosynth-asset: cd8251de8c40e239ad24dcf9ed93ea2708a3eed5
126126
refs/heads/autosynth-automl: cced2f56bbef0499609073edbca6253e1df5e535
127-
refs/heads/autosynth-bigquerydatatransfer: fb2b690c57acdd37c2ac957788155606b28d5d9f
127+
refs/heads/autosynth-bigquerydatatransfer: 6e2c2dd890fe445cc896f0ddcb30309213759ee2
128128
refs/heads/autosynth-bigquerystorage: 99aee05df348f39d98b6fb23c292006f1d2a6c28
129129
refs/heads/autosynth-bigtable: fa0d1de9e264d7ecac8a3abc3de7a8364cfaf427
130130
refs/heads/autosynth-bigtable-admin: 6379a2bc712f2736c83de0e009b4d26da4fa82ca

branches/autosynth-bigquerydatatransfer/google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/AckReplyConsumer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ public interface AckReplyConsumer {
2929
* message.
3030
*/
3131
void nack();
32+
33+
void abandon();
3234
}

branches/autosynth-bigquerydatatransfer/google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/MessageDispatcher.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ private class AckHandler implements ApiFutureCallback<AckReply> {
133133
private final int outstandingBytes;
134134
private final long receivedTimeMillis;
135135
private final Instant totalExpiration;
136+
private boolean extending = true;
136137

137138
AckHandler(String ackId, int outstandingBytes, Instant totalExpiration) {
138139
this.ackId = ackId;
@@ -151,6 +152,7 @@ private void forget() {
151152
*/
152153
return;
153154
}
155+
extending = false;
154156
flowController.release(1, outstandingBytes);
155157
messagesWaiter.incrementPendingMessages(-1);
156158
processOutstandingBatches();
@@ -417,6 +419,11 @@ public void ack() {
417419
public void nack() {
418420
response.set(AckReply.NACK);
419421
}
422+
423+
@Override
424+
public void abandon() {
425+
ackHandler.forget();
426+
}
420427
};
421428
ApiFutures.addCallback(response, ackHandler, MoreExecutors.directExecutor());
422429
executor.execute(
@@ -471,6 +478,9 @@ void extendDeadlines() {
471478
Instant extendTo = now.plusSeconds(extendSeconds);
472479

473480
for (Map.Entry<String, AckHandler> entry : pendingMessages.entrySet()) {
481+
if (!entry.getValue().extending) {
482+
continue;
483+
}
474484
String ackId = entry.getKey();
475485
Instant totalExpiration = entry.getValue().totalExpiration;
476486
if (totalExpiration.isAfter(extendTo)) {

branches/autosynth-bigquerydatatransfer/google-cloud-clients/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/MessageDispatcherTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ public void testNack() throws Exception {
148148
assertThat(sentModAcks).contains(ModAckItem.of(TEST_MESSAGE.getAckId(), 0));
149149
}
150150

151+
@Test
152+
public void testAbandon() throws Exception {
153+
dispatcher.processReceivedMessages(Collections.singletonList(TEST_MESSAGE), NOOP_RUNNABLE);
154+
consumers.take().abandon();
155+
dispatcher.extendDeadlines();
156+
assertThat(sentModAcks).doesNotContain(TEST_MESSAGE.getAckId());
157+
}
158+
151159
@Test
152160
public void testExtension() throws Exception {
153161
dispatcher.processReceivedMessages(Collections.singletonList(TEST_MESSAGE), NOOP_RUNNABLE);

0 commit comments

Comments
 (0)