- try {
- Await.result(actorSystem.terminate(), Duration.create(10, TimeUnit.SECONDS));
- } catch (final Exception e) {
- LOG.warn("Error awaiting actor termination", e);
- }
+ final Future<Terminated> ret = actorSystem.terminate();
+ ret.onComplete(new OnComplete<Terminated>() {
+ @Override
+ public void onComplete(final Throwable failure, final Terminated success) throws Throwable {
+ if (failure != null) {
+ LOG.warn("ActorSystem failed to shut down", failure);
+ } else {
+ LOG.info("ActorSystem shut down");
+ }
+ }
+ }, ExecutionContext.global());
+ return ret;
+ }
+
+ public void close(final FiniteDuration wait) throws TimeoutException, InterruptedException {
+ Await.result(asyncClose(), wait);
+ }
+
+ @Override
+ public void close() throws TimeoutException, InterruptedException {
+ close(FiniteDuration.create(10, TimeUnit.SECONDS));