resend deposit confirmed and payment sent messages more often until ack

This commit is contained in:
woodser 2025-02-18 08:16:13 -05:00
parent e4fa5f520d
commit 4d765fa5d9
2 changed files with 14 additions and 5 deletions

View File

@ -66,7 +66,7 @@ import lombok.extern.slf4j.Slf4j;
public abstract class BuyerSendPaymentSentMessage extends SendMailboxMessageTask { public abstract class BuyerSendPaymentSentMessage extends SendMailboxMessageTask {
private ChangeListener<MessageState> listener; private ChangeListener<MessageState> listener;
private Timer timer; private Timer timer;
private static final int MAX_RESEND_ATTEMPTS = 10; private static final int MAX_RESEND_ATTEMPTS = 20;
private int delayInMin = 10; private int delayInMin = 10;
private int resendCounter = 0; private int resendCounter = 0;
@ -198,7 +198,16 @@ public abstract class BuyerSendPaymentSentMessage extends SendMailboxMessageTask
onMessageStateChange(processModel.getPaymentSentMessageStateProperty().get()); onMessageStateChange(processModel.getPaymentSentMessageStateProperty().get());
} }
delayInMin = delayInMin * 2; // first re-send is after 2 minutes, then increase the delay exponentially
if (resendCounter == 0) {
int shortDelay = 2;
log.info("We will send the message again to the peer after a delay of {} min.", shortDelay);
timer = UserThread.runAfter(this::run, shortDelay, TimeUnit.MINUTES);
} else {
log.info("We will send the message again to the peer after a delay of {} min.", delayInMin);
timer = UserThread.runAfter(this::run, delayInMin, TimeUnit.MINUTES);
delayInMin = (int) ((double) delayInMin * 1.5);
}
resendCounter++; resendCounter++;
} }

View File

@ -37,7 +37,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public abstract class SendDepositsConfirmedMessage extends SendMailboxMessageTask { public abstract class SendDepositsConfirmedMessage extends SendMailboxMessageTask {
private Timer timer; private Timer timer;
private static final int MAX_RESEND_ATTEMPTS = 10; private static final int MAX_RESEND_ATTEMPTS = 20;
private int delayInMin = 10; private int delayInMin = 10;
private int resendCounter = 0; private int resendCounter = 0;
@ -137,7 +137,7 @@ public abstract class SendDepositsConfirmedMessage extends SendMailboxMessageTas
timer.stop(); timer.stop();
} }
// first re-send is after 2 minutes, then double the delay each iteration // first re-send is after 2 minutes, then increase the delay exponentially
if (resendCounter == 0) { if (resendCounter == 0) {
int shortDelay = 2; int shortDelay = 2;
log.info("We will send the message again to the peer after a delay of {} min.", shortDelay); log.info("We will send the message again to the peer after a delay of {} min.", shortDelay);
@ -145,7 +145,7 @@ public abstract class SendDepositsConfirmedMessage extends SendMailboxMessageTas
} else { } else {
log.info("We will send the message again to the peer after a delay of {} min.", delayInMin); log.info("We will send the message again to the peer after a delay of {} min.", delayInMin);
timer = UserThread.runAfter(this::run, delayInMin, TimeUnit.MINUTES); timer = UserThread.runAfter(this::run, delayInMin, TimeUnit.MINUTES);
delayInMin = delayInMin * 2; delayInMin = (int) ((double) delayInMin * 1.5);
} }
resendCounter++; resendCounter++;
} }