0 Replies Latest reply on Dec 22, 2015 5:57 AM by Iaroslav Savytskyi

    Request Scope in async calls

    Iaroslav Savytskyi Newbie

      I have a problem to accessed request data from @Asynchronous methods.


      Here is the example:


      public class CurrentUserService implements Serializable {

        public String token;


      public class Service {

         private RestClient client;

          private ManagedExecutorService executorService;

          private ContextService contextService;

          private <T> Future<T> getFuture(Supplier<T> supplier) {

              Callable<T> task = supplier::get;

              Callable<T> callable = contextService.createContextualProxy(task, Callable.class);

              return executorService.submit(callable);



         public String getToken() throws Exception {

            return getFuture(client::getToken).get();




      public class RestClient {

          private CurrentUserService currentUserBean;


          public String getToken() {

              return currentUserBean.getToken();



      It's expected that request scoped data should be accessible within tasks executed within request scope. But it's not. Is it a bug? May be I'm doing something wrong? If yes - what it the correct way to propagate such data into async calls?


      Thanks in advance.