Skip to content

Commit cc40dd4

Browse files
committed
---
yaml --- r: 26227 b: refs/heads/pubsub-ordering-keys c: ad54d69 h: refs/heads/master i: 26225: 8f5ff03 26223: 05293c3
1 parent 2de36d8 commit cc40dd4

7 files changed

Lines changed: 878 additions & 66 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ refs/tags/v0.72.0: a7703f2593ba312c0b2dde6fdfd4f5c764bb55ac
155155
refs/tags/v0.73.0: 21241ea8be9439cc5764c4944cdce21d34ce4f9e
156156
refs/tags/v0.74.0: 9d1f733dbbf790de7b494418523b69c4a9a57638
157157
refs/heads/ignoretest: 23c412ae07af3d0ab1caa2d44d5bc5c0ccb8b31d
158-
refs/heads/pubsub-ordering-keys: 262b5af368038754e192e0b32e53ba7319464a06
158+
refs/heads/pubsub-ordering-keys: ad54d6980fb0208a4d2cf253c9f8cc8336893b69
159159
"refs/heads/update_mvn_badge": ae2d773814db0f71197ccf5a8612ee1d8056f8de
160160
refs/tags/v0.75.0: c3673089ae09a897c1b4cf7dfe167fe4f8ab32fb
161161
refs/tags/v0.76.0: 395b016826d3ddf9cb8b34919636df15a4dbd032

branches/pubsub-ordering-keys/google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/MessageDispatcher.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class MessageDispatcher {
6262
@InternalApi static final Duration PENDING_ACKS_SEND_DELAY = Duration.ofMillis(100);
6363

6464
private final Executor executor;
65+
private final SequentialExecutorService sequentialExecutor;
6566
private final ScheduledExecutorService systemExecutor;
6667
private final ApiClock clock;
6768

@@ -209,6 +210,7 @@ void sendAckOperations(
209210
jobLock = new ReentrantLock();
210211
messagesWaiter = new MessageWaiter();
211212
this.clock = clock;
213+
this.sequentialExecutor = new SequentialExecutorService(executor);
212214
}
213215

214216
public void start() {
@@ -353,7 +355,7 @@ public void nack() {
353355
}
354356
};
355357
ApiFutures.addCallback(response, ackHandler, MoreExecutors.directExecutor());
356-
executor.execute(
358+
Runnable deliverMessageTask =
357359
new Runnable() {
358360
@Override
359361
public void run() {
@@ -374,7 +376,12 @@ public void run() {
374376
response.setException(e);
375377
}
376378
}
377-
});
379+
};
380+
if (message.getOrderingKey().isEmpty()) {
381+
executor.execute(deliverMessageTask);
382+
} else {
383+
sequentialExecutor.submit(message.getOrderingKey(), deliverMessageTask);
384+
}
378385
}
379386

380387
/** Compute the ideal deadline, set subsequent modacks to this deadline, and return it. */

0 commit comments

Comments
 (0)