Asynchronous SMS notification

background:

       The company's old system of user feedback, send SMS abnormal ......

Examination revealed Bulk SMS interface times out, the front end direct throw an exception, and instead sent asynchronously ......

    @Autowired
    private ThreadPoolTaskExecutor executor;







//			mobileMessageReadService.batchSend(messages);
//			store.setSmsCount(smsCount - messages.size());
//			storeWriteService.update(store);

            // 批量超时,改为异步
            CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> mobileMessageReadService.batchSend(messages), executor);
            future.whenComplete((r, e) -> {
                if (r) {
                    store.setSmsCount(smsCount - messages.size());
                    storeWriteService.update(store);
                }
            });

 

ThreadPoolTaskExecutor custom thread pool ( elegant thread pool )

Upon receiving the result of the synchronous message transmission remaining article number.

Published 33 original articles · won praise 6 · views 10000 +

Guess you like

Origin blog.csdn.net/kuangni5808/article/details/102841801