IIUC this method is running inside the container managed transaction?  Does it 
send the response immediately if it’s not in a container managed transaction?

david jencks

> On Oct 18, 2019, at 10:21 AM, Paul Carter-Brown <[email protected]> 
> wrote:
> 
> Hi,
> 
> In this code sample, why is it that it takes 3s for the "OK" response to
> get back to the client.
> My expectation would be that the response would go back immediately?
> 
> @Path("/abc")
> @Stateless
> public class BasicResource {
> 
>    @PersistenceContext()
>    private EntityManager em;
> 
>    @GET
>    @Produces(MediaType.TEXT_PLAIN)
>    public void test(@Suspended final AsyncResponse asyncResponse) {
>        // Want OK to get to the client immediately
>        asyncResponse.resume("OK");
>        try {
>            // Some long running JDBC transactional stuff to run in JTA
> container managed transaction using injected em
>            // That must commit when done
>            Thread.sleep(3000);
>        } catch (Exception e) {
>        }
>    }
> }
> 
> Paul

Reply via email to