Skip to content

Commit

Permalink
Switch webhook logic to wait for each optout to succeed before sendin…
Browse files Browse the repository at this point in the history
…g the next one.
  • Loading branch information
lionell-pack-ttd committed Mar 15, 2024
1 parent f13e870 commit b676343
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/main/java/com/uid2/optout/vertx/OptOutSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,25 @@ private void deltaReplay(Promise<Void> promise, OptOutCollection store, List<Str
Future<Void> lastOp = Future.succeededFuture();
for (int i = 0; i < store.size(); ++i) {
final OptOutEntry entry = store.get(i);
Future<Void> sendOp = this.remotePartner.send(entry);
sendOp.onComplete(v -> {
if (v.succeeded()) {
recordEntryReplayStatus("success");
this.lastEntrySent.set(entry.timestamp);
} else {
if (v.cause() instanceof TooManyRetriesException) {
recordEntryReplayStatus("too_many_retries");
} else if (v.cause() instanceof UnexpectedStatusCodeException) {
recordEntryReplayStatus("unexpected_status_code_" + ((UnexpectedStatusCodeException) v.cause()).getStatusCode());
lastOp = lastOp.compose(ar -> {
Future<Void> sendOp = this.remotePartner.send(entry);
return sendOp.onComplete(v -> {
if (v.succeeded()) {
recordEntryReplayStatus("success");
this.lastEntrySent.set(entry.timestamp);
} else {
recordEntryReplayStatus("unknown_error");
if (v.cause() instanceof TooManyRetriesException) {
recordEntryReplayStatus("too_many_retries");
} else if (v.cause() instanceof UnexpectedStatusCodeException) {
recordEntryReplayStatus("unexpected_status_code_" + ((UnexpectedStatusCodeException) v.cause()).getStatusCode());
} else {
recordEntryReplayStatus("unknown_error");
}

this.logger.error("deltaReplay failed sending entry: " + entry.timestamp, v.cause());
}

this.logger.error("deltaReplay failed sending entry: " + entry.timestamp, v.cause());
}
});
});

lastOp = lastOp.compose(v -> sendOp);
}

lastOp.onComplete(ar -> {
Expand Down

0 comments on commit b676343

Please sign in to comment.