REQ-3201: fix bugs

This commit is contained in:
yanglin 2024-12-18 16:23:44 +08:00
parent 087f6d6bf2
commit 31966401b6
2 changed files with 6 additions and 4 deletions

View File

@ -87,7 +87,7 @@ public class CardManager {
.reloadAndLogCards("send:enqueue");
});
PushDeviceSnapshots deviceSnapshots = pushDeviceService.createDeviceSnapshots();
CardSendExecutor batchExecutor = new CardSendExecutor(executor);
CardSendExecutor batchExecutor = new CardSendExecutor(request, executor);
for (CardGroup group : sendModel.getCardGroups()) {
batchExecutor.submit(() -> {
SendTemplateMessageParam imRequest = cardSupport.buildImSendRequest(

View File

@ -14,21 +14,23 @@ import java.util.concurrent.atomic.AtomicReference;
class CardSendExecutor {
private final AsyncRunTasks asyncTasks;
private final Object request;
private final AtomicReference<Exception> error = new AtomicReference<>();
private int submitCount = 0;
CardSendExecutor(ExecutorService executor) {
CardSendExecutor(Object request, ExecutorService executor) {
this.asyncTasks = new AsyncRunTasks(executor);
this.request = request;
}
void submit(Runnable sender) {
submitCount++;
if (submitCount <= 4) {
log.info("using sync card send, submitBatchSize={}", submitCount);
log.info("using sync card send, submitBatchSize={}, request={}", submitCount, request);
sender.run();
return;
}
log.info("using async card send, submitBatchSize={}", submitCount);
log.info("using async card send, submitBatchSize={}, request={}", submitCount, request);
asyncTasks.runAsync(() -> {
Exception exception = error.get();
if (exception != null) {