• Post Reply Bookmark Topic Watch Topic
  • New Topic

JEE6 @Asynchronous annotation and threading question

 
Steinar Dahl
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm developing a JEE6 application (in glassfish3) with a lot of background processing and I'm trying
to figure out how the @Asynchrounous tag works when it comes to threading.

What I'm trying to do is to trigger multithreaded background processing from a single EJB call from a client by
calling a private method in the same EJB multiple times. This private method is annotated @Asynchrounous but when
I debug it looks like there is one single thread that processes all calls to this method in the background.

Is there anyway to configure this behaviour ? Running backgound processing triggered by a single client call in one
single thread is not an option in this project since that will cause a big loss in performance.

Thankful for any help with this

Regards
Steinar Dahl
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steinar Dahl wrote:
What I'm trying to do is to trigger multithreaded background processing from a single EJB call from a client by
calling a private method in the same EJB multiple times. This private method is annotated @Asynchrounous but when
I debug it looks like there is one single thread that processes all calls to this method in the background.



1) @Asynchronous behaviour in EJB3.1 applies only for "business methods". What that means is you can't apply that on a private method of that bean. The method should either be exposed via a remote business interface or a local business interface or a no-interface view, for it to qualify as a business method

2) Calling any method in a bean from some other method within that bean, using this (for ex: this.doSomeOtherOp()) doesn't give you any EJB semantics on that method. It acts just like a plain java object call. To get EJB semantics on that call, you will have to invoke that method on the proxy (a.k.a business object) of that bean. See this for an example.

 
Steinar Dahl
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot, it helped to call another EJB instead of a private method.

Kind Regards
Steinar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!