Russell,
Calling any method from inside an EJB via 'this' is an internal call
that bypasses any container involvement.
-marina
Collins, Russell wrote:
> I am wondering how this @Asynchronous annotation is tor work in
> Glassfish 3.0.1. Currently, this does not produce any type of
> Asynchronous processing as far as I can tell. Here is my class
>
>
> @Stateless(name = "Order")
> public class Order implements IOrderLocal {
>
>
> @Override
> public void processOrder() {
>
>
> Future<String> o1 = this.m1();
> Future<String> o2 = this.m2();
>
> System.out.println(o1);
> System.out.println(o2);
>
> }
>
>
>
> @Asynchronous
> public Future<String> m1() {
>
> boolean truth = true;
> int n = 0;
>
> System.out.println("Inside m1");
>
> while(truth) {
>
> n += 1;
> if (100 == n)
> truth = false;
>
> System.out.println("Inside m1 loop");
> }
>
> System.out.println("About to return m1");
> return new javax.ejb.AsyncResult<String>("Hello, Async 1 World!");
> }
>
> @Asynchronous
> public Future<String> m2() {
>
> System.out.println("About to return m2");
> return new javax.ejb.AsyncResult<String>("Hello, Async 2 World!");
> }
> }
>
>
>
> The first time I ran this, I ran a loop 10 times. The result is as
> follows:
>
> INFO: Inside m1
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: About to return m1
> INFO: About to return m2
> INFO: javax.ejb.AsyncResult_at_1cf166b2
> <mailto:javax.ejb.AsyncResult_at_1cf166b2>
> INFO: javax.ejb.AsyncResult_at_1cf16add
> <mailto:javax.ejb.AsyncResult_at_1cf16add>
>
> When I run it 100 times. The result is as follows:
>
>
> INFO: Inside m1
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: Inside m1 loop
> INFO: About to return m1
> INFO: About to return m2
> INFO: javax.ejb.AsyncResult_at_1cd1d81c
> <mailto:javax.ejb.AsyncResult_at_1cd1d81c>
> INFO: javax.ejb.AsyncResult_at_1cd1f33d
> <mailto:javax.ejb.AsyncResult_at_1cd1f33d>
>
> In both instances, the second "asynchrous" call is not being executed
> until the first one is complete. I would like both methods to execute
> at the same time. Is this a JEE thing or is this a bug in Glassfih 3.0.1?
>
>
> *Russell Collins*
> Sr. Software Engineer
> CoreLogic Spatial Solutions
> Direct: 512.977.3206
> rcollins_at_corelogic.com <mailto:rcollins_at_corelogic.com>
>
>
>
> "Do or do not, there is no try." - Yoda
>
>
>
> ******************************************************************************************
>
> This message may contain confidential or proprietary information
> intended only for the use of the
> addressee(s) named above or may contain information that is legally
> privileged. If you are
> not the intended addressee, or the person responsible for delivering
> it to the intended addressee,
> you are hereby notified that reading, disseminating, distributing or
> copying this message is strictly
> prohibited. If you have received this message by mistake, please
> immediately notify us by
> replying to the message and delete the original message and any copies
> immediately thereafter.
>
> Thank you.
> ******************************************************************************************
>
> CLLD
> ------------------------------------------------------------------------
>