Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public class TransactionalMessageServiceImpl implements TransactionalMessageServ
private static final int MAX_PROCESS_TIME_LIMIT = 60000;
private static final int MAX_RETRY_TIMES_FOR_ESCAPE = 10;

static long escapeRetryBackoffMillis(int escapeFailCnt) {
return 100L * (1 << escapeFailCnt);
}

private static final int MAX_RETRY_COUNT_WHEN_HALF_NULL = 1;

private static final int OP_MSG_PULL_NUMS = 32;
Expand Down Expand Up @@ -250,7 +254,7 @@ public void check(long transactionTimeout, int transactionCheckMax,
msgExt.getUserProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX));
if (escapeFailCnt < MAX_RETRY_TIMES_FOR_ESCAPE) {
escapeFailCnt++;
Thread.sleep(100L * (2 ^ escapeFailCnt));
Thread.sleep(escapeRetryBackoffMillis(escapeFailCnt));
} else {
escapeFailCnt = 0;
newOffset = i + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public void init() {
queueTransactionMsgService = new TransactionalMessageServiceImpl(bridge);
}

@Test
public void testEscapeRetryBackoffMillisIsExponential() {
for (int i = 1; i <= 10; i++) {
assertThat(TransactionalMessageServiceImpl.escapeRetryBackoffMillis(i)).isEqualTo(100L * (1L << i));
}
}

@Test
public void testPrepareMessage() {
MessageExtBrokerInner inner = createMessageBrokerInner();
Expand Down