I have an EJB A that invokes EJB B. The UI should not wait for more than 30 seconds for a response. If some data is missing, it should return a partial response.
How can I define a timeout (time limit of 30 seconds) on EJB B?
I can define EJB B as Asynchronous that returns Future, and then do Future.get(30, TimeUnit.SECONDS).
But is it the best solution?
thank you
P.S. I use glassfish 3.1
To configure timeout for a bean which applies to all its methods, you have to configure the attribute
cmt-timeout-in-secondsin glassfish-ejb-jar.xml.This timeout value is used by all the methods of the bean that initiates a new transaction, not applicable when they join other ongoing transaction.
Also can refer this link for further details on timeout.