@Test public void testAsyncSend() throws InterruptedException { int id = (int) (System.currentTimeMillis() / 1000); producer.asyncSend(id).addCallback(new ListenableFutureCallback<Void>() { @Override public void onFailure(Throwable e) { logger.info("[testASyncSend][发送编号：[{}] 发送异常]]", id, e); } @Override public void onSuccess(Void aVoid) { logger.info("[testASyncSend][发送编号：[{}] 发送成功，发送成功]", id); } }); logger.info("[testASyncSend][发送编号：[{}] 调用完成]", id); new CountDownLatch(1).await(); }
@Async public ListenableFuture<Void> asyncSend(Integer id) { try { this.syncSend(id); return AsyncResult.forValue(null); } catch (Throwable ex) { return AsyncResult.forExecutionException(ex); } }
Demo01Producer { @Async public ListenableFuture<Void> asyncSend(Integer id) { try { this.syncSend(id); return AsyncResult.forValue(null); } catch (Throwable ex) { return AsyncResult.forExecutionException(ex); } } }
Demo01Producer { @Async public ListenableFuture<Void> asyncSend(Integer id) { try { this.syncSend(id); return AsyncResult.forValue(null); } catch (Throwable ex) { return AsyncResult.forExecutionException(ex); } }  }
Demo01Producer { @Async public ListenableFuture<Void> asyncSend(Integer id) { try { this.syncSend(id); return AsyncResult.forValue(null); } catch (Throwable ex) { return AsyncResult.forExecutionException(ex); } }  void syncSend(Integer id); void syncSendDefault(Integer id); @Async ListenableFuture<Void> asyncSend(Integer id); }
Demo01Producer { @Async public ListenableFuture<Void> asyncSend(Integer id) { try { this.syncSend(id); return AsyncResult.forValue(null); } catch (Throwable ex) { return AsyncResult.forExecutionException(ex); } }  void syncSend(Integer id); void syncSendDefault(Integer id); @Async ListenableFuture<Void> asyncSend(Integer id);  }