Skip to content

Commit f5dd5a6

Browse files
author
Yang Guo
committed
optimize code structure
1 parent 850a35d commit f5dd5a6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

platform-api/src/main/java/com/flow/platform/api/consumer/CmdCallbackQueueConsumer.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,21 @@ public void onQueueItem(CmdCallbackQueueItem item) {
5353
try {
5454
jobService.callback(item);
5555
} catch (NotFoundException notFoundException) {
56-
// wait 1s re queue
57-
try {
58-
Thread.sleep(1000);
59-
} catch (Throwable throwable) {
60-
}
6156

62-
jobService.enterQueue(item);
57+
// re-enqueue cmd callback if job not found since transaction problem
58+
reEnqueueJobCallback(item, 1000);
6359

6460
} catch (Throwable throwable) {
6561
LOGGER.traceMarker("onQueueItem", String.format("exception - %s", throwable));
6662
}
6763
}
64+
65+
private void reEnqueueJobCallback(CmdCallbackQueueItem item, long wait) {
66+
try {
67+
Thread.sleep(wait);
68+
} catch (Throwable ignore) {
69+
}
70+
71+
jobService.enterQueue(item);
72+
}
6873
}

0 commit comments

Comments
 (0)