/**
   * Demonstrate how to call an asynchronous EJB and continue local work meanwhile. After finishing
   * local work wait for the result of the server call.<br>
   * Remember that the call of Future.get() will have a remote roundtrip to the server.
   */
  private void waitForAsyncResult()
      throws InterruptedException, ExecutionException, TimeoutException {
    Future<String> myResult = accessBean.longerRunning(1500); // Start a call with a short duration
    // you might do something here

    // get() without a timeout will wait until the remote result is present.
    LOGGER.info("Got the async result as expected after wait => " + myResult.get());
  }
 /**
  * Demonstrate how to call an asynchronous EJB, and then perform another task whilst waiting for
  * the result. If the result is not present after the timeout of get(<timeout>) the result will be
  * ignored.
  *
  * @throws TimeoutException Will be thrown if you change the timing
  */
 private void getResultAsync() throws InterruptedException, ExecutionException, TimeoutException {
   Future<String> myResult = accessBean.longerRunning(200); // Start a call with a short duration
   // simulate something
   // wait below 200ms will force a timeout during get
   Thread.sleep(400);
   // If you handle the TimeoutException you are able to ignore the result
   // WARNING: there might be an ERROR at server side that the result is not delivered
   LOGGER.info("Got the async result as expected => " + myResult.get(1, TimeUnit.MILLISECONDS));
 }