Search code examples
javaejbjava-ee-6java-ee-7open-liberty

@RequestScoped + new thread


We use javaEE RequestScoped with OpenLiberty and new threads via EJB @Asynchronous. I am just curious what the actual value comes from when we inject RequestScoped bean inside a new thread? Will the RequestScoped bean be freshly initialized? Or will it be pulled from the latest request?


Solution

  • In OpenLiberty, you'll get a new request scope every time you make an EJB @Asynchronous call, meaning that you'll get a new freshly initialized instance of any injected RequestScoped beans while you're within that method call.