-
1. Re: Asynchronous Database Queries
cjalmeida Jun 13, 2008 8:03 PM (in response to stephanos)Check chapter 19 of docs
which deals with asynchronicity.From there, you can easily call asynchronous methods while having full access to the seam context.
Just some not-so-well documented caveats:
1) The implementation is based on either the EJB Timer service or Quartz. I've found that the Quartz implementation is far more reliable.
2) If you use anything but Quartz configured for in-memory job storage, You'll probably run into transaction problems if your datasources are not XA. Check the wiki for help configuring them. Also, MySQL Connectors and XA Transactions is lottery game! If thing blow for no reason, you might want to check tem.
-
2. Re: Asynchronous Database Queries
stephanos Jun 13, 2008 10:03 PM (in response to stephanos)Well, thank you for your reply.
I am familiar with that part of the documentation. Maybe me question was not clear enough.
In the documentation you got the example of calling a void method. In my case, I want to call 2 methods which both return a value (e.g. user and contract data).
I am not sure you to build a system that
waits
for the calls and only then proceeds... -
3. Re: Asynchronous Database Queries
dan.j.allen Jun 14, 2008 7:24 AM (in response to stephanos)What you are probably looking for is a method that returns a handle to the task, which must be done using the EJBTimer implementation (or Quartz if it supports it). Then you can keep checking that task until it is finished and read off the data. I would check the EJB documentation for this one, because this is actually separate from Seam. Seam just facilitates the use of the asynchronous mechanism.
By the way, you left out an implementation. By default, Seam uses the Java 5 concurrent library to execute asynchronous methods. There are three limitations with it: it is not persistence (meaning the task might never execute), it does not support scheduling, and (I think) you cannot monitor the task.
-
4. Re: Asynchronous Database Queries
stephanos Jun 14, 2008 9:11 AM (in response to stephanos)Thanks very much for the reply!
-
5. Re: Asynchronous Database Queries
cjalmeida Jun 16, 2008 5:36 AM (in response to stephanos)True. My bad :)
BTW, I've posted a patch in JIRA to inject the QuartzTriggerHandle into the context - the same behavior of the EJB Timer implementation.
Otherwise, I couldn't make a repeating job cancel itself.