Make an EJB call with a timeout

I have an EJB Athat calls an EJB B. The user interface should not wait for a response for more than 30 seconds. If some data is missing, it should return a partial response.

How to determine the timeout (time limit of 30 seconds) on an EJB B?

I can define EJB Bas Asynchronouswhich returns Futureand then does Future.get(30, TimeUnit.SECONDS). But is this the best solution?

Thank you

PS I'm using glass fish 3.1

+5
source share
3 answers

To set a timeout for a bean that applies to all of its methods, you must configure the attribute cmt-timeout-in-secondsin glassfish-ejb-jar.xml.

bean, , , .

-.

0

EJB. , EJB , .

@Asynchronous Future.get, ; EJB . Future.cancel SessionContext.wasCancelCalled.

+2

All Articles